------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\markd\Dropbox\Mark Research\Working Papers\Gibler-Nieman\Split-sample alliance\JoP Final\Replication\Main Analysis\NiemanGibler_JOP_demdiff.log
  log type:  text
 opened on:  25 Sep 2020, 13:21:30

. /* Doug Gibler and Mark Nieman */
> /* Data Analysis for Taking Democratic Differences Seriously */
> /* Input: NiemanGibler_demdiff_ally.dta, NiemanGibler_demdiff_trade */
> /* Output:  Table 1, Figure 1, Neglible effect test, Figure 2, Figure 3 */
> 
> /* Preamble */
> clear;

. estimates clear;

. set memory 4g;

. program drop _all;

. clear matrix;

. tempfile full;

. set seed 17;

.         /* Create the split-sample logit */
>                 #delimit;
delimiter now ;
.                 program define ssp_lf, rclass;
  1.                                         args lnf beta gamma ;
  2.                         tempvar rel violate;
  3.                                 quietly gen double `rel' = 1/(1+exp(-`gamma'));
  4.                                 quietly gen double `violate' = 1/(1+exp(-`beta'));
  5.                         quietly replace `lnf' = ln((1-`rel')+(`rel'*(1-`violate'))) if $ML_y1==0;
  6.                                 quietly replace `lnf' = ln((`rel')*(`violate')) if $ML_y1==1;
  7.                 end;

.                         /* Calculate Rubin formula for uncertainty */
>                 capture program drop rubin;

.                 program define rubin;
  1.                         local names: colnames(Q1);
  2.                         /* MI param estimates */
>                         matrix Q = (Q1 + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9 + Q10)/10;
  3.                         /* MI covariances     */
>                         matrix W = (W1 + W2 + W3 + W4 + W5 + W6 + W7 + W8 + W9 + W10)/10;
  4.                                         matrix ll = (ll1 + ll2 + ll3 + ll4 + ll5 + ll6 + ll7 + ll8 + ll9 + ll10)/10;
  5.                         local  k = colsof(Q);
  6.                         forvalues i=1/10 {;
  7.                           matrix QQ=Q`i'-Q;
  8.                           if `i'==1 {;
  9.                                 matrix B=(QQ)'*QQ;
 10.                                 };
 11.                           else matrix B = B + (QQ)'*QQ;
 12.                         };
 13.                         /* Covariance adjustment */
>                         matrix B=B/(10-1);
 14.                                         /* Final covariance   */
>                         matrix V=W+(1+1/10)*B;
 15.                                                         ereturn post Q V ;
 16.                 end;

. /* Load alliance data */
>         use NiemanGibler_demdiff_ally, clear;

. /* Table 1 */
>         /* Replicate Leeds et al (Model 1) and identify shared observations*/
>         #delimit;
delimiter now ;
.         logit violate wcchangedA capcheither20 regchangeeither chTEAltorBmt alformA demdA 
>                 asymmetry  nomicoop treaty milinst time timesquare timecube
>                 , robust cluster(atopidphase);

Iteration 0:   log pseudolikelihood = -387.99838  
Iteration 1:   log pseudolikelihood = -365.94879  
Iteration 2:   log pseudolikelihood = -352.46294  
Iteration 3:   log pseudolikelihood = -352.39382  
Iteration 4:   log pseudolikelihood = -352.39377  
Iteration 5:   log pseudolikelihood = -352.39377  

Logistic regression                             Number of obs     =      6,612
                                                Wald chi2(13)     =      87.50
                                                Prob > chi2       =     0.0000
Log pseudolikelihood = -352.39377               Pseudo R2         =     0.0918

                             (Std. Err. adjusted for 223 clusters in atopidphase)
---------------------------------------------------------------------------------
                |               Robust
        violate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
----------------+----------------------------------------------------------------
     wcchangedA |   .8887726   .4360017     2.04   0.042      .034225     1.74332
  capcheither20 |   .8031506   .3303636     2.43   0.015     .1556499    1.450651
regchangeeither |   .1307584   .3076127     0.43   0.671    -.4721514    .7336682
   chTEAltorBmt |   .4211639   .2704212     1.56   0.119    -.1088519    .9511798
        alformA |   1.069867   .2533108     4.22   0.000     .5733865    1.566347
          demdA |  -1.322405   .3928941    -3.37   0.001    -2.092463   -.5523467
      asymmetry |  -.4079564    .259061    -1.57   0.115    -.9157066    .0997939
       nomicoop |  -.7456285   .2574683    -2.90   0.004    -1.250257   -.2409999
         treaty |  -.0826596   .3543504    -0.23   0.816    -.7771735    .6118543
        milinst |   .5569792   .1798905     3.10   0.002     .2044004     .909558
           time |  -.0864409   .0766854    -1.13   0.260    -.2367416    .0638597
     timesquare |   .0008638   .0043956     0.20   0.844    -.0077515    .0094791
       timecube |   .0000152   .0000659     0.23   0.817    -.0001139    .0001443
          _cons |  -4.448444   .4404076   -10.10   0.000    -5.311627   -3.585261
---------------------------------------------------------------------------------

.         estimates store LMV;

.         gen LMV=1 if e(sample)==1;
(230 missing values generated)

.         matrix lmv_b = e(b);

.         matrix lmv_se = e(V);

.         /* Run Relevancy equation to identify shared observations*/
>         logit violate TerrThreat2 num_dems_on_border  num_borders  cold 
>                 Lenergy_pop Oil_exp  maj_pow kgd_riv , cluster(atopidphase) robust;

Iteration 0:   log pseudolikelihood = -397.11044  
Iteration 1:   log pseudolikelihood = -372.12723  
Iteration 2:   log pseudolikelihood = -367.23431  
Iteration 3:   log pseudolikelihood = -367.12351  
Iteration 4:   log pseudolikelihood = -367.12322  
Iteration 5:   log pseudolikelihood = -367.12322  

Logistic regression                             Number of obs     =      6,618
                                                Wald chi2(8)      =      68.13
                                                Prob > chi2       =     0.0000
Log pseudolikelihood = -367.12322               Pseudo R2         =     0.0755

                                (Std. Err. adjusted for 234 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
           violate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
       TerrThreat2 |    4.01077    .916538     4.38   0.000     2.214388    5.807151
num_dems_on_border |  -.2410896   .1509834    -1.60   0.110    -.5370117    .0548325
       num_borders |   .0093427   .0601482     0.16   0.877    -.1085455     .127231
           coldwar |  -.0707733   .2510075    -0.28   0.778    -.5627389    .4211923
       Lenergy_pop |  -.2073064   .0706459    -2.93   0.003    -.3457699   -.0688429
           Oil_exp |   .3122076   .3221711     0.97   0.333    -.3192361    .9436514
           maj_pow |   .5734007   .3625857     1.58   0.114    -.1372543    1.284056
         kgd_rival |   .2830081   .3562347     0.79   0.427     -.415199    .9812153
             _cons |  -5.258307   .3515344   -14.96   0.000    -5.947302   -4.569313
------------------------------------------------------------------------------------

.         gen GT=1 if e(sample)==1;
(224 missing values generated)

.         matrix B1 = e(b);

.         /* Idenity cases in both samples*/
>         gen GL=0;

.         replace GL=1 if GT==1 & LMV==1;
(6,395 real changes made)

.         /* Save temp file to use later */
>         save `full', replace;
(note: file C:\Users\markd\AppData\Local\Temp\ST_00000001.tmp not found)
file C:\Users\markd\AppData\Local\Temp\ST_00000001.tmp saved

.         /* Rerun on Leeds et al on same sample (GL) (Model 2)*/
>         logit violate wcchangedA capcheither20 regchangeeither chTEAltorBmt alformA demdA 
>                 asymmetry  nomicoop treaty milinst time timesquare timecube if GL==1
>                 , robust cluster (atopidphase);

Iteration 0:   log pseudolikelihood = -376.61313  
Iteration 1:   log pseudolikelihood =  -355.4945  
Iteration 2:   log pseudolikelihood = -340.04896  
Iteration 3:   log pseudolikelihood = -339.98841  
Iteration 4:   log pseudolikelihood = -339.98837  
Iteration 5:   log pseudolikelihood = -339.98837  

Logistic regression                             Number of obs     =      6,395
                                                Wald chi2(13)     =      87.13
                                                Prob > chi2       =     0.0000
Log pseudolikelihood = -339.98837               Pseudo R2         =     0.0972

                             (Std. Err. adjusted for 223 clusters in atopidphase)
---------------------------------------------------------------------------------
                |               Robust
        violate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
----------------+----------------------------------------------------------------
     wcchangedA |    .909608   .4443062     2.05   0.041     .0387838    1.780432
  capcheither20 |   .8772921   .3395701     2.58   0.010      .211747    1.542837
regchangeeither |   .1951832   .3076624     0.63   0.526    -.4078241    .7981905
   chTEAltorBmt |   .4251498   .2781558     1.53   0.126    -.1200255    .9703251
        alformA |   1.063735   .2606154     4.08   0.000     .5529379    1.574531
          demdA |  -1.341269   .4006138    -3.35   0.001    -2.126457   -.5560801
      asymmetry |  -.5026752   .2646211    -1.90   0.057    -1.021323    .0159726
       nomicoop |  -.7462648   .2606457    -2.86   0.004    -1.257121   -.2354087
         treaty |  -.1335719   .3552336    -0.38   0.707    -.8298171    .5626732
        milinst |   .5747953   .1859543     3.09   0.002     .2103315     .939259
           time |  -.0692453   .0763633    -0.91   0.365    -.2189147    .0804241
     timesquare |   -.000215   .0043416    -0.05   0.961    -.0087243    .0082943
       timecube |   .0000306   .0000643     0.48   0.634    -.0000954    .0001565
          _cons |  -4.464314   .4547396    -9.82   0.000    -5.355588   -3.573041
---------------------------------------------------------------------------------

.         estimates store LMV2;

.         matrix B2 = e(b);

.         matrix ll_lmv = e(ll);

.         /* Model 3*/
>         /* Split-sample model applying Rubin for uncertainty in estimates */
>         forvalues i=1/10 {;
  2.         ml model lf ssp_lf  
>                 (B: violate = wcchangedA capcheither20 regchangeeither chTEAltorBmt alformA demdA 
>                 asymmetry  nomicoop treaty milinst time timesquare timecube)
>                 (G: violate = TerrThreat`i' num_dems_on_border   num_borders  
>                  cold Lenergy_pop Oil_exp maj_pow kgd_riv  ) if GL==1 
>                 , robust cluster(atopidphase) tech(nr);
  3.         ml init B2 B1 , copy ;
  4.         ml search;
  5.         ml maximize, diff;
  6.         matrix Q`i' = e(b);
  7.                 matrix W`i' = e(V);
  8.                 matrix  ll`i' = e(ll);
  9.                 matrix chi`i' = e(chi2);
 10.                 nois _dots `i' 0;
 11.         };
initial:       log pseudolikelihood = -552.47368
rescale:       log pseudolikelihood = -339.68952
rescale eq:    log pseudolikelihood = -339.68952

initial:       log pseudolikelihood = -339.68952
rescale:       log pseudolikelihood = -339.68952
rescale eq:    log pseudolikelihood = -339.68952
Iteration 0:   log pseudolikelihood = -339.68952  
Iteration 1:   log pseudolikelihood = -321.73965  (not concave)
Iteration 2:   log pseudolikelihood = -321.05365  (not concave)
Iteration 3:   log pseudolikelihood = -320.78617  (not concave)
Iteration 4:   log pseudolikelihood = -320.66678  (not concave)
Iteration 5:   log pseudolikelihood = -320.56004  (not concave)
Iteration 6:   log pseudolikelihood = -320.44894  (not concave)
Iteration 7:   log pseudolikelihood = -320.34551  (not concave)
Iteration 8:   log pseudolikelihood = -320.24554  (not concave)
Iteration 9:   log pseudolikelihood = -320.14186  (not concave)
Iteration 10:  log pseudolikelihood = -320.03717  (not concave)
Iteration 11:  log pseudolikelihood =  -319.9323  (not concave)
Iteration 12:  log pseudolikelihood = -319.82666  (not concave)
Iteration 13:  log pseudolikelihood = -319.71861  (not concave)
Iteration 14:  log pseudolikelihood = -319.60904  (not concave)
Iteration 15:  log pseudolikelihood = -319.49736  (not concave)
Iteration 16:  log pseudolikelihood = -319.38407  (not concave)
Iteration 17:  log pseudolikelihood = -319.26817  (not concave)
Iteration 18:  log pseudolikelihood = -319.15048  (not concave)
Iteration 19:  log pseudolikelihood = -319.03016  (not concave)
Iteration 20:  log pseudolikelihood =  -318.9081  (not concave)
Iteration 21:  log pseudolikelihood = -318.78339  (not concave)
Iteration 22:  log pseudolikelihood = -318.65707  (not concave)
Iteration 23:  log pseudolikelihood = -318.52823  (not concave)
Iteration 24:  log pseudolikelihood = -318.39805  (not concave)
Iteration 25:  log pseudolikelihood =  -318.2656  (not concave)
Iteration 26:  log pseudolikelihood = -318.13216  (not concave)
Iteration 27:  log pseudolikelihood =  -317.9968  (not concave)
Iteration 28:  log pseudolikelihood = -317.86089  (not concave)
Iteration 29:  log pseudolikelihood = -317.72348  (not concave)
Iteration 30:  log pseudolikelihood = -317.58601  (not concave)
Iteration 31:  log pseudolikelihood = -317.44752  (not concave)
Iteration 32:  log pseudolikelihood = -317.30947  (not concave)
Iteration 33:  log pseudolikelihood = -317.17088  (not concave)
Iteration 34:  log pseudolikelihood = -317.03323  (not concave)
Iteration 35:  log pseudolikelihood = -316.89551  (not concave)
Iteration 36:  log pseudolikelihood = -316.75919  
Iteration 37:  log pseudolikelihood = -313.88128  
Iteration 38:  log pseudolikelihood = -308.34848  (not concave)
Iteration 39:  log pseudolikelihood = -308.13015  
Iteration 40:  log pseudolikelihood = -307.76776  
Iteration 41:  log pseudolikelihood = -307.66044  
Iteration 42:  log pseudolikelihood = -307.65809  
Iteration 43:  log pseudolikelihood = -307.65807  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      38.18
Log pseudolikelihood = -307.65807               Prob > chi2       =     0.0003

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.554612   5.265973     1.05   0.292    -4.766505    15.87573
     capcheither20 |   3.025849   2.237058     1.35   0.176    -1.358703    7.410401
   regchangeeither |   1.722877     1.2905     1.34   0.182    -.8064559    4.252209
      chTEAltorBmt |   .7588391   1.250519     0.61   0.544    -1.692134    3.209812
           alformA |   2.429555   1.611208     1.51   0.132    -.7283551    5.587465
             demdA |    1.32545   1.899559     0.70   0.485    -2.397618    5.048518
         asymmetry |  -1.629199   .9071899    -1.80   0.073    -3.407259    .1488601
          nomicoop |  -2.681801   1.201954    -2.23   0.026    -5.037588   -.3260145
            treaty |   1.530365   2.361134     0.65   0.517    -3.097373    6.158103
           milinst |   4.958687   2.420578     2.05   0.041     .2144403    9.702933
              time |  -.1220182   .2722484    -0.45   0.654    -.6556152    .4115788
        timesquare |  -.0028001   .0100434    -0.28   0.780    -.0224847    .0168846
          timecube |   .0000856   .0001223     0.70   0.484     -.000154    .0003252
             _cons |  -3.204682   1.492731    -2.15   0.032    -6.130381   -.2789836
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat1 |   4.164642   1.092018     3.81   0.000     2.024327    6.304958
num_dems_on_border |  -.3052036   .1211805    -2.52   0.012    -.5427131   -.0676941
       num_borders |   .1213709   .0626635     1.94   0.053    -.0014473    .2441892
           coldwar |   .4054614   .3056685     1.33   0.185    -.1936379    1.004561
       Lenergy_pop |  -.1538508   .0826612    -1.86   0.063    -.3158639    .0081622
           Oil_exp |   .6716013   .5156591     1.30   0.193    -.3390719    1.682274
           maj_pow |   .4872248   .5133659     0.95   0.343    -.5189538    1.493403
         kgd_rival |  -.0088577   .3996553    -0.02   0.982    -.7921677    .7744524
             _cons |  -4.968495   .5542195    -8.96   0.000    -6.054745   -3.882245
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -551.97197
rescale:       log pseudolikelihood = -339.13933
rescale eq:    log pseudolikelihood = -339.13933

initial:       log pseudolikelihood = -339.13933
rescale:       log pseudolikelihood = -339.13933
rescale eq:    log pseudolikelihood = -339.13933
Iteration 0:   log pseudolikelihood = -339.13933  
Iteration 1:   log pseudolikelihood = -320.59533  (not concave)
Iteration 2:   log pseudolikelihood =  -319.8469  (not concave)
Iteration 3:   log pseudolikelihood = -319.62568  (not concave)
Iteration 4:   log pseudolikelihood = -319.49534  (not concave)
Iteration 5:   log pseudolikelihood = -319.36898  (not concave)
Iteration 6:   log pseudolikelihood = -319.10422  (not concave)
Iteration 7:   log pseudolikelihood = -318.96264  (not concave)
Iteration 8:   log pseudolikelihood = -318.37194  (not concave)
Iteration 9:   log pseudolikelihood = -318.06542  (not concave)
Iteration 10:  log pseudolikelihood = -317.90631  (not concave)
Iteration 11:  log pseudolikelihood = -317.77784  (not concave)
Iteration 12:  log pseudolikelihood = -317.65835  (not concave)
Iteration 13:  log pseudolikelihood = -317.51645  (not concave)
Iteration 14:  log pseudolikelihood =  -317.3026  (not concave)
Iteration 15:  log pseudolikelihood = -317.12981  (not concave)
Iteration 16:  log pseudolikelihood = -316.96558  (not concave)
Iteration 17:  log pseudolikelihood = -315.33566  
Iteration 18:  log pseudolikelihood = -311.82347  
Iteration 19:  log pseudolikelihood = -307.19292  (not concave)
Iteration 20:  log pseudolikelihood =  -307.0203  
Iteration 21:  log pseudolikelihood = -307.01302  
Iteration 22:  log pseudolikelihood = -306.80898  
Iteration 23:  log pseudolikelihood = -306.79002  
Iteration 24:  log pseudolikelihood = -306.78981  
Iteration 25:  log pseudolikelihood = -306.78981  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      38.09
Log pseudolikelihood = -306.78981               Prob > chi2       =     0.0003

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.360357   5.215517     1.03   0.304    -4.861868    15.58258
     capcheither20 |   3.060694   2.807385     1.09   0.276    -2.441679    8.563068
   regchangeeither |    1.71702   1.443008     1.19   0.234    -1.111223    4.545263
      chTEAltorBmt |   .8126552   1.442671     0.56   0.573    -2.014927    3.640238
           alformA |   2.531837   2.058451     1.23   0.219    -1.502652    6.566327
             demdA |   1.311128   2.032478     0.65   0.519    -2.672455    5.294711
         asymmetry |  -1.568129   .9767569    -1.61   0.108    -3.482537    .3462794
          nomicoop |  -2.619418   1.197038    -2.19   0.029     -4.96557   -.2732666
            treaty |   1.396548   2.605935     0.54   0.592    -3.710991    6.504087
           milinst |   5.014686   2.350554     2.13   0.033     .4076846    9.621688
              time |   -.130797   .3057139    -0.43   0.669    -.7299852    .4683912
        timesquare |  -.0023197   .0104374    -0.22   0.824    -.0227766    .0181372
          timecube |   .0000796   .0001235     0.64   0.519    -.0001624    .0003215
             _cons |   -3.19826   1.463564    -2.19   0.029    -6.066793   -.3297265
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat2 |    4.15696   1.048078     3.97   0.000     2.102765    6.211156
num_dems_on_border |  -.2921913   .1196168    -2.44   0.015    -.5266359   -.0577468
       num_borders |   .1194812    .065489     1.82   0.068     -.008875    .2478373
           coldwar |   .4624649   .3289697     1.41   0.160    -.1823039    1.107234
       Lenergy_pop |   -.151949   .0852471    -1.78   0.075    -.3190301    .0151322
           Oil_exp |   .6673647   .5420852     1.23   0.218    -.3951027    1.729832
           maj_pow |   .3975153   .5380823     0.74   0.460    -.6571066    1.452137
         kgd_rival |   .0162721   .3974921     0.04   0.967    -.7627981    .7953423
             _cons |  -4.984371   .5947418    -8.38   0.000    -6.150044   -3.818698
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -550.88632
rescale:       log pseudolikelihood = -339.36653
rescale eq:    log pseudolikelihood = -339.36653

initial:       log pseudolikelihood = -339.36653
rescale:       log pseudolikelihood = -339.36653
rescale eq:    log pseudolikelihood = -339.36653
Iteration 0:   log pseudolikelihood = -339.36653  
Iteration 1:   log pseudolikelihood = -322.24441  (not concave)
Iteration 2:   log pseudolikelihood =  -321.6619  (not concave)
Iteration 3:   log pseudolikelihood = -321.37208  (not concave)
Iteration 4:   log pseudolikelihood = -321.17392  (not concave)
Iteration 5:   log pseudolikelihood =  -320.9653  (not concave)
Iteration 6:   log pseudolikelihood = -320.69892  (not concave)
Iteration 7:   log pseudolikelihood = -320.30824  (not concave)
Iteration 8:   log pseudolikelihood = -320.16758  (not concave)
Iteration 9:   log pseudolikelihood = -320.02509  (not concave)
Iteration 10:  log pseudolikelihood =  -319.5457  (not concave)
Iteration 11:  log pseudolikelihood = -319.09778  (not concave)
Iteration 12:  log pseudolikelihood = -318.86776  (not concave)
Iteration 13:  log pseudolikelihood = -318.67691  (not concave)
Iteration 14:  log pseudolikelihood = -318.52104  (not concave)
Iteration 15:  log pseudolikelihood = -318.38404  (not concave)
Iteration 16:  log pseudolikelihood = -318.25122  (not concave)
Iteration 17:  log pseudolikelihood = -318.11672  (not concave)
Iteration 18:  log pseudolikelihood = -317.97976  (not concave)
Iteration 19:  log pseudolikelihood = -317.84196  (not concave)
Iteration 20:  log pseudolikelihood =  -317.7056  (not concave)
Iteration 21:  log pseudolikelihood = -317.56829  (not concave)
Iteration 22:  log pseudolikelihood =  -317.4313  (not concave)
Iteration 23:  log pseudolikelihood = -317.29432  (not concave)
Iteration 24:  log pseudolikelihood = -317.15888  
Iteration 25:  log pseudolikelihood = -313.71856  
Iteration 26:  log pseudolikelihood = -308.71112  
Iteration 27:  log pseudolikelihood = -308.51907  
Iteration 28:  log pseudolikelihood = -308.08375  
Iteration 29:  log pseudolikelihood =  -308.0585  
Iteration 30:  log pseudolikelihood = -308.05802  
Iteration 31:  log pseudolikelihood = -308.05802  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      37.58
Log pseudolikelihood = -308.05802               Prob > chi2       =     0.0003

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.496283   4.654747     1.18   0.238    -3.626853    14.61942
     capcheither20 |   3.081114   2.282289     1.35   0.177    -1.392091    7.554319
   regchangeeither |     1.7496   1.355371     1.29   0.197    -.9068781    4.406078
      chTEAltorBmt |   .7538751   1.296213     0.58   0.561    -1.786656    3.294406
           alformA |   2.457386   1.666996     1.47   0.140    -.8098666    5.724638
             demdA |   1.270367   1.795648     0.71   0.479    -2.249037    4.789772
         asymmetry |  -1.648224   .9139988    -1.80   0.071    -3.439628     .143181
          nomicoop |  -2.730386   1.180032    -2.31   0.021    -5.043207   -.4175647
            treaty |   1.520888   2.330098     0.65   0.514     -3.04602    6.087795
           milinst |   4.967339   2.365332     2.10   0.036     .3313728    9.603306
              time |  -.1243215   .2790606    -0.45   0.656    -.6712702    .4226271
        timesquare |  -.0027891   .0101164    -0.28   0.783     -.022617    .0170387
          timecube |   .0000857   .0001223     0.70   0.484    -.0001541    .0003254
             _cons |  -3.177391   1.429941    -2.22   0.026    -5.980023   -.3747586
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat3 |   3.919003   1.064852     3.68   0.000     1.831931    6.006076
num_dems_on_border |  -.3056505   .1207269    -2.53   0.011    -.5422709   -.0690302
       num_borders |   .1176692   .0627606     1.87   0.061    -.0053393    .2406778
           coldwar |   .3971341   .3105728     1.28   0.201    -.2115773    1.005846
       Lenergy_pop |  -.1516354   .0824638    -1.84   0.066    -.3132615    .0099908
           Oil_exp |   .7003274   .5233634     1.34   0.181    -.3254461    1.726101
           maj_pow |   .4721018   .5033937     0.94   0.348    -.5145317    1.458735
         kgd_rival |   -.002245   .3996183    -0.01   0.996    -.7854825    .7809925
             _cons |  -4.926025   .5511316    -8.94   0.000    -6.006223   -3.845827
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -548.54478
rescale:       log pseudolikelihood = -338.34789
rescale eq:    log pseudolikelihood = -338.34789

initial:       log pseudolikelihood = -338.34789
rescale:       log pseudolikelihood = -338.34789
rescale eq:    log pseudolikelihood = -338.34789
Iteration 0:   log pseudolikelihood = -338.34789  
Iteration 1:   log pseudolikelihood = -320.08366  (not concave)
Iteration 2:   log pseudolikelihood = -319.47072  (not concave)
Iteration 3:   log pseudolikelihood = -319.20192  (not concave)
Iteration 4:   log pseudolikelihood = -318.98135  (not concave)
Iteration 5:   log pseudolikelihood = -318.78576  (not concave)
Iteration 6:   log pseudolikelihood = -318.22047  (not concave)
Iteration 7:   log pseudolikelihood = -317.61746  (not concave)
Iteration 8:   log pseudolikelihood = -317.48771  (not concave)
Iteration 9:   log pseudolikelihood =  -317.3584  (not concave)
Iteration 10:  log pseudolikelihood = -317.23663  (not concave)
Iteration 11:  log pseudolikelihood = -317.11381  (not concave)
Iteration 12:  log pseudolikelihood = -316.98687  (not concave)
Iteration 13:  log pseudolikelihood = -316.85884  (not concave)
Iteration 14:  log pseudolikelihood = -316.72956  (not concave)
Iteration 15:  log pseudolikelihood = -316.59952  (not concave)
Iteration 16:  log pseudolikelihood = -316.46753  (not concave)
Iteration 17:  log pseudolikelihood = -316.33515  (not concave)
Iteration 18:  log pseudolikelihood = -316.20154  (not concave)
Iteration 19:  log pseudolikelihood = -316.06797  (not concave)
Iteration 20:  log pseudolikelihood = -315.93347  (not concave)
Iteration 21:  log pseudolikelihood = -315.79946  (not concave)
Iteration 22:  log pseudolikelihood = -315.66498  (not concave)
Iteration 23:  log pseudolikelihood = -315.53142  (not concave)
Iteration 24:  log pseudolikelihood =  -315.3978  (not concave)
Iteration 25:  log pseudolikelihood =  -315.2655  
Iteration 26:  log pseudolikelihood = -310.94145  
Iteration 27:  log pseudolikelihood = -307.04378  
Iteration 28:  log pseudolikelihood = -306.31839  
Iteration 29:  log pseudolikelihood = -306.25324  
Iteration 30:  log pseudolikelihood = -306.23436  
Iteration 31:  log pseudolikelihood = -306.23417  
Iteration 32:  log pseudolikelihood = -306.23417  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      38.71
Log pseudolikelihood = -306.23417               Prob > chi2       =     0.0002

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.629505   5.679801     0.99   0.322    -5.502701    16.76171
     capcheither20 |    2.97668   2.022733     1.47   0.141    -.9878034    6.941163
   regchangeeither |   1.711962   1.218388     1.41   0.160     -.676034    4.099959
      chTEAltorBmt |   .7364693   1.192232     0.62   0.537    -1.600262    3.073201
           alformA |   2.414497   1.457869     1.66   0.098    -.4428739    5.271868
             demdA |   1.381923   1.898085     0.73   0.467    -2.338254    5.102101
         asymmetry |  -1.655563   .8773496    -1.89   0.059    -3.375137    .0640106
          nomicoop |  -2.675561   1.198498    -2.23   0.026    -5.024573   -.3265487
            treaty |   1.614673   2.367109     0.68   0.495    -3.024775     6.25412
           milinst |   4.850592   2.732755     1.77   0.076    -.5055102    10.20669
              time |  -.1176123   .2604284    -0.45   0.652    -.6280426    .3928179
        timesquare |  -.0029914    .009907    -0.30   0.763    -.0224088    .0164261
          timecube |   .0000881   .0001216     0.72   0.469    -.0001503    .0003265
             _cons |  -3.251313   1.598963    -2.03   0.042    -6.385223   -.1174038
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat4 |   4.107257   .9396432     4.37   0.000      2.26559    5.948924
num_dems_on_border |  -.2832182   .1231507    -2.30   0.021    -.5245892   -.0418472
       num_borders |   .1173514   .0614777     1.91   0.056    -.0031426    .2378455
           coldwar |   .4641928   .3063714     1.52   0.130    -.1362841     1.06467
       Lenergy_pop |  -.1541604   .0824374    -1.87   0.061    -.3157347    .0074139
           Oil_exp |   .6911795   .4980617     1.39   0.165    -.2850035    1.667363
           maj_pow |   .4213874   .5013376     0.84   0.401    -.5612162    1.403991
         kgd_rival |  -.0022924   .3972073    -0.01   0.995    -.7808044    .7762196
             _cons |  -5.004813   .5431101    -9.22   0.000     -6.06929   -3.940337
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -551.64885
rescale:       log pseudolikelihood = -339.40605
rescale eq:    log pseudolikelihood = -339.40605

initial:       log pseudolikelihood = -339.40605
rescale:       log pseudolikelihood = -339.40605
rescale eq:    log pseudolikelihood = -339.40605
Iteration 0:   log pseudolikelihood = -339.40605  
Iteration 1:   log pseudolikelihood = -321.60243  (not concave)
Iteration 2:   log pseudolikelihood = -320.89205  (not concave)
Iteration 3:   log pseudolikelihood = -320.69069  (not concave)
Iteration 4:   log pseudolikelihood = -320.55376  (not concave)
Iteration 5:   log pseudolikelihood = -320.43551  (not concave)
Iteration 6:   log pseudolikelihood = -320.32212  (not concave)
Iteration 7:   log pseudolikelihood =  -320.2092  (not concave)
Iteration 8:   log pseudolikelihood = -320.09632  (not concave)
Iteration 9:   log pseudolikelihood = -319.98326  (not concave)
Iteration 10:  log pseudolikelihood = -319.87029  (not concave)
Iteration 11:  log pseudolikelihood =  -319.7558  (not concave)
Iteration 12:  log pseudolikelihood = -319.64022  (not concave)
Iteration 13:  log pseudolikelihood = -319.52271  (not concave)
Iteration 14:  log pseudolikelihood = -319.40388  (not concave)
Iteration 15:  log pseudolikelihood = -319.28258  (not concave)
Iteration 16:  log pseudolikelihood = -319.15958  (not concave)
Iteration 17:  log pseudolikelihood =  -319.0339  (not concave)
Iteration 18:  log pseudolikelihood = -318.90646  (not concave)
Iteration 19:  log pseudolikelihood = -318.77621  (not concave)
Iteration 20:  log pseudolikelihood = -318.64421  (not concave)
Iteration 21:  log pseudolikelihood = -318.50946  (not concave)
Iteration 22:  log pseudolikelihood = -318.37316  (not concave)
Iteration 23:  log pseudolikelihood = -318.23428  (not concave)
Iteration 24:  log pseudolikelihood = -318.09418  (not concave)
Iteration 25:  log pseudolikelihood = -317.95181  (not concave)
Iteration 26:  log pseudolikelihood = -317.80866  (not concave)
Iteration 27:  log pseudolikelihood = -317.66367  (not concave)
Iteration 28:  log pseudolikelihood =  -317.5184  (not concave)
Iteration 29:  log pseudolikelihood = -317.37179  (not concave)
Iteration 30:  log pseudolikelihood = -317.22546  (not concave)
Iteration 31:  log pseudolikelihood = -317.07832  (not concave)
Iteration 32:  log pseudolikelihood = -316.93202  (not concave)
Iteration 33:  log pseudolikelihood = -316.78545  (not concave)
Iteration 34:  log pseudolikelihood = -316.64024  
Iteration 35:  log pseudolikelihood = -312.18509  (backed up)
Iteration 36:  log pseudolikelihood =  -308.1503  
Iteration 37:  log pseudolikelihood = -307.37894  
Iteration 38:  log pseudolikelihood = -307.28768  
Iteration 39:  log pseudolikelihood = -307.28545  
Iteration 40:  log pseudolikelihood = -307.28544  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      39.28
Log pseudolikelihood = -307.28544               Prob > chi2       =     0.0002

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.469102   4.875895     1.12   0.262    -4.087476    15.02568
     capcheither20 |   2.963231   2.033639     1.46   0.145    -1.022628     6.94909
   regchangeeither |   1.672278   1.221249     1.37   0.171    -.7213269    4.065883
      chTEAltorBmt |   .7436778   1.186757     0.63   0.531    -1.582322    3.069678
           alformA |   2.419019   1.451603     1.67   0.096    -.4260697    5.264109
             demdA |   1.377005   1.774794     0.78   0.438    -2.101527    4.855537
         asymmetry |  -1.635586   .8881004    -1.84   0.066    -3.376231    .1050585
          nomicoop |  -2.675159   1.188628    -2.25   0.024    -5.004828   -.3454906
            treaty |   1.548525   2.116891     0.73   0.464    -2.600506    5.697555
           milinst |   4.995851   1.943858     2.57   0.010      1.18596    8.805743
              time |  -.1218649   .2661784    -0.46   0.647    -.6435649    .3998351
        timesquare |  -.0026171   .0100616    -0.26   0.795    -.0223375    .0171032
          timecube |   .0000826   .0001231     0.67   0.502    -.0001586    .0003239
             _cons |   -3.21761   1.396681    -2.30   0.021    -5.955054   -.4801666
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat5 |   4.103619   1.033101     3.97   0.000     2.078779    6.128459
num_dems_on_border |   -.296764   .1228346    -2.42   0.016    -.5375155   -.0560125
       num_borders |    .121201    .061346     1.98   0.048      .000965     .241437
           coldwar |    .423853   .2957745     1.43   0.152    -.1558544     1.00356
       Lenergy_pop |  -.1511682   .0834747    -1.81   0.070    -.3147756    .0124392
           Oil_exp |    .669086   .4991337     1.34   0.180    -.3091981     1.64737
           maj_pow |   .4117937   .5040262     0.82   0.414    -.5760796    1.399667
         kgd_rival |  -.0059914   .3979043    -0.02   0.988    -.7858696    .7738867
             _cons |  -4.937248   .5317657    -9.28   0.000    -5.979489   -3.895006
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -551.18564
rescale:       log pseudolikelihood = -339.08565
rescale eq:    log pseudolikelihood = -339.08565

initial:       log pseudolikelihood = -339.08565
rescale:       log pseudolikelihood = -339.08565
rescale eq:    log pseudolikelihood = -339.08565
Iteration 0:   log pseudolikelihood = -339.08565  
Iteration 1:   log pseudolikelihood = -321.44292  (not concave)
Iteration 2:   log pseudolikelihood =  -320.7451  (not concave)
Iteration 3:   log pseudolikelihood = -320.52114  (not concave)
Iteration 4:   log pseudolikelihood = -320.39054  (not concave)
Iteration 5:   log pseudolikelihood = -320.25558  (not concave)
Iteration 6:   log pseudolikelihood =  -319.0521  (not concave)
Iteration 7:   log pseudolikelihood = -318.62635  (not concave)
Iteration 8:   log pseudolikelihood = -318.48774  (not concave)
Iteration 9:   log pseudolikelihood = -318.34218  (not concave)
Iteration 10:  log pseudolikelihood = -315.21992  
Iteration 11:  log pseudolikelihood = -310.25402  
Iteration 12:  log pseudolikelihood = -307.60441  
Iteration 13:  log pseudolikelihood = -307.42632  
Iteration 14:  log pseudolikelihood = -307.33802  
Iteration 15:  log pseudolikelihood = -307.33608  
Iteration 16:  log pseudolikelihood = -307.33606  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      39.09
Log pseudolikelihood = -307.33606               Prob > chi2       =     0.0002

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.336783     4.8375     1.10   0.270    -4.144544    14.81811
     capcheither20 |   2.969731   2.162434     1.37   0.170    -1.268562    7.208024
   regchangeeither |   1.659496   1.239862     1.34   0.181    -.7705889    4.089581
      chTEAltorBmt |   .7703614   1.221363     0.63   0.528    -1.623465    3.164188
           alformA |   2.444198   1.560159     1.57   0.117     -.613658    5.502055
             demdA |   1.367137   1.806399     0.76   0.449     -2.17334    4.907614
         asymmetry |  -1.596956   .9052345    -1.76   0.078    -3.371183    .1772711
          nomicoop |   -2.61482   1.171633    -2.23   0.026    -4.911179   -.3184605
            treaty |   1.479536   2.215492     0.67   0.504    -2.862748     5.82182
           milinst |   5.049671   1.895969     2.66   0.008     1.333639    8.765703
              time |  -.1239421   .2691562    -0.46   0.645    -.6514785    .4035943
        timesquare |  -.0025687   .0100098    -0.26   0.797    -.0221875    .0170501
          timecube |   .0000824    .000122     0.68   0.499    -.0001567    .0003214
             _cons |  -3.216397   1.398882    -2.30   0.021    -5.958156   -.4746383
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat6 |   3.688224   .9171145     4.02   0.000     1.890713    5.485736
num_dems_on_border |  -.3010495   .1216264    -2.48   0.013    -.5394328   -.0626661
       num_borders |   .1331053   .0615219     2.16   0.030     .0125245    .2536861
           coldwar |   .4339991   .3006261     1.44   0.149    -.1552172    1.023215
       Lenergy_pop |   -.152002   .0830565    -1.83   0.067    -.3147898    .0107858
           Oil_exp |    .637554   .5030851     1.27   0.205    -.3484747    1.623583
           maj_pow |   .3958488    .514067     0.77   0.441     -.611704    1.403402
         kgd_rival |    .032555   .3981054     0.08   0.935    -.7477173    .8128273
             _cons |  -4.954145   .5439021    -9.11   0.000    -6.020173   -3.888116
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -551.61193
rescale:       log pseudolikelihood = -338.97794
rescale eq:    log pseudolikelihood = -338.97794

initial:       log pseudolikelihood = -338.97794
rescale:       log pseudolikelihood = -338.97794
rescale eq:    log pseudolikelihood = -338.97794
Iteration 0:   log pseudolikelihood = -338.97794  
Iteration 1:   log pseudolikelihood = -320.01138  (not concave)
Iteration 2:   log pseudolikelihood = -319.28888  (not concave)
Iteration 3:   log pseudolikelihood = -319.07505  (not concave)
Iteration 4:   log pseudolikelihood =  -318.9299  (not concave)
Iteration 5:   log pseudolikelihood = -318.79913  (not concave)
Iteration 6:   log pseudolikelihood = -318.66676  (not concave)
Iteration 7:   log pseudolikelihood = -318.54145  (not concave)
Iteration 8:   log pseudolikelihood = -318.41999  (not concave)
Iteration 9:   log pseudolikelihood =  -318.2967  (not concave)
Iteration 10:  log pseudolikelihood = -318.17345  (not concave)
Iteration 11:  log pseudolikelihood = -318.05039  (not concave)
Iteration 12:  log pseudolikelihood = -317.92741  (not concave)
Iteration 13:  log pseudolikelihood =  -317.8029  (not concave)
Iteration 14:  log pseudolikelihood = -317.67775  (not concave)
Iteration 15:  log pseudolikelihood = -317.55112  (not concave)
Iteration 16:  log pseudolikelihood = -317.42375  (not concave)
Iteration 17:  log pseudolikelihood = -317.29456  (not concave)
Iteration 18:  log pseudolikelihood = -317.16451  (not concave)
Iteration 19:  log pseudolikelihood = -317.03267  (not concave)
Iteration 20:  log pseudolikelihood = -316.90009  (not concave)
Iteration 21:  log pseudolikelihood = -316.76577  (not concave)
Iteration 22:  log pseudolikelihood = -316.63092  (not concave)
Iteration 23:  log pseudolikelihood = -316.49456  (not concave)
Iteration 24:  log pseudolikelihood = -316.35797  (not concave)
Iteration 25:  log pseudolikelihood = -316.22016  (not concave)
Iteration 26:  log pseudolikelihood = -316.08248  (not concave)
Iteration 27:  log pseudolikelihood = -315.94394  (not concave)
Iteration 28:  log pseudolikelihood = -315.80595  (not concave)
Iteration 29:  log pseudolikelihood = -315.66749  (not concave)
Iteration 30:  log pseudolikelihood = -315.52998  (not concave)
Iteration 31:  log pseudolikelihood = -315.39241  (not concave)
Iteration 32:  log pseudolikelihood = -315.25618  
Iteration 33:  log pseudolikelihood = -311.17305  
Iteration 34:  log pseudolikelihood = -306.92601  
Iteration 35:  log pseudolikelihood = -306.21319  
Iteration 36:  log pseudolikelihood = -306.13571  
Iteration 37:  log pseudolikelihood = -306.12099  
Iteration 38:  log pseudolikelihood = -306.12078  
Iteration 39:  log pseudolikelihood = -306.12078  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      39.88
Log pseudolikelihood = -306.12078               Prob > chi2       =     0.0001

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.722254   7.282342     0.79   0.432    -8.550873    19.99538
     capcheither20 |   2.904073   2.031369     1.43   0.153    -1.077337    6.885483
   regchangeeither |   1.663788   1.135388     1.47   0.143    -.5615315    3.889108
      chTEAltorBmt |   .7555236   1.133015     0.67   0.505    -1.465146    2.976193
           alformA |   2.397415   1.416926     1.69   0.091    -.3797088    5.174539
             demdA |    1.48039   2.170499     0.68   0.495     -2.77371    5.734489
         asymmetry |  -1.615463   .8757322    -1.84   0.065    -3.331866    .1009408
          nomicoop |  -2.594962   1.251942    -2.07   0.038    -5.048724   -.1412004
            treaty |   1.615045   2.513304     0.64   0.520     -3.31094     6.54103
           milinst |   4.814385   2.883969     1.67   0.095    -.8380896    10.46686
              time |  -.1212086   .2543396    -0.48   0.634    -.6197051    .3772879
        timesquare |  -.0026567   .0098994    -0.27   0.788    -.0220591    .0167458
          timecube |   .0000837    .000123     0.68   0.496    -.0001574    .0003249
             _cons |  -3.304625   1.757022    -1.88   0.060    -6.748325    .1390748
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat7 |   4.177885     .96423     4.33   0.000     2.288029    6.067741
num_dems_on_border |  -.2865775   .1235835    -2.32   0.020    -.5287967   -.0443583
       num_borders |   .1294324   .0605501     2.14   0.033     .0107563    .2481085
           coldwar |   .4772023   .3032766     1.57   0.116    -.1172089    1.071614
       Lenergy_pop |  -.1546998   .0830992    -1.86   0.063    -.3175712    .0081715
           Oil_exp |   .6520867   .4992568     1.31   0.192    -.3264386    1.630612
           maj_pow |   .4104294   .5229115     0.78   0.433    -.6144583    1.435317
         kgd_rival |   .0053867   .3960681     0.01   0.989    -.7708925     .781666
             _cons |  -5.032428   .5547266    -9.07   0.000    -6.119672   -3.945184
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -552.24246
rescale:       log pseudolikelihood = -339.64514
rescale eq:    log pseudolikelihood = -339.64514

initial:       log pseudolikelihood = -339.64514
rescale:       log pseudolikelihood = -339.64514
rescale eq:    log pseudolikelihood = -339.64514
Iteration 0:   log pseudolikelihood = -339.64514  
Iteration 1:   log pseudolikelihood = -322.27872  (not concave)
Iteration 2:   log pseudolikelihood = -321.61055  (not concave)
Iteration 3:   log pseudolikelihood = -321.35474  (not concave)
Iteration 4:   log pseudolikelihood = -321.23791  (not concave)
Iteration 5:   log pseudolikelihood = -321.13241  (not concave)
Iteration 6:   log pseudolikelihood = -321.02691  (not concave)
Iteration 7:   log pseudolikelihood = -320.92383  (not concave)
Iteration 8:   log pseudolikelihood = -320.82214  (not concave)
Iteration 9:   log pseudolikelihood = -320.71913  (not concave)
Iteration 10:  log pseudolikelihood = -320.61541  (not concave)
Iteration 11:  log pseudolikelihood = -320.51059  (not concave)
Iteration 12:  log pseudolikelihood = -320.40486  (not concave)
Iteration 13:  log pseudolikelihood = -320.29702  (not concave)
Iteration 14:  log pseudolikelihood = -320.18764  (not concave)
Iteration 15:  log pseudolikelihood =  -320.0759  (not concave)
Iteration 16:  log pseudolikelihood =  -319.9624  (not concave)
Iteration 17:  log pseudolikelihood = -319.84618  (not concave)
Iteration 18:  log pseudolikelihood =   -319.728  (not concave)
Iteration 19:  log pseudolikelihood = -319.60695  (not concave)
Iteration 20:  log pseudolikelihood = -319.48394  (not concave)
Iteration 21:  log pseudolikelihood =   -319.358  (not concave)
Iteration 22:  log pseudolikelihood = -319.23019  (not concave)
Iteration 23:  log pseudolikelihood = -319.09955  (not concave)
Iteration 24:  log pseudolikelihood = -318.96728  (not concave)
Iteration 25:  log pseudolikelihood = -318.83239  (not concave)
Iteration 26:  log pseudolikelihood =  -318.6962  (not concave)
Iteration 27:  log pseudolikelihood = -318.55774  (not concave)
Iteration 28:  log pseudolikelihood = -318.41843  (not concave)
Iteration 29:  log pseudolikelihood = -318.27728  (not concave)
Iteration 30:  log pseudolikelihood =  -318.1358  (not concave)
Iteration 31:  log pseudolikelihood = -317.99297  (not concave)
Iteration 32:  log pseudolikelihood = -317.85036  (not concave)
Iteration 33:  log pseudolikelihood = -317.70693  (not concave)
Iteration 34:  log pseudolikelihood = -317.56426  (not concave)
Iteration 35:  log pseudolikelihood = -317.42129  (not concave)
Iteration 36:  log pseudolikelihood =  -317.2796  
Iteration 37:  log pseudolikelihood =   -314.045  (backed up)
Iteration 38:  log pseudolikelihood = -308.67708  
Iteration 39:  log pseudolikelihood = -308.47257  
Iteration 40:  log pseudolikelihood = -307.98339  
Iteration 41:  log pseudolikelihood = -307.95143  
Iteration 42:  log pseudolikelihood = -307.95059  
Iteration 43:  log pseudolikelihood = -307.95058  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      37.96
Log pseudolikelihood = -307.95058               Prob > chi2       =     0.0003

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.387778   4.321406     1.25   0.212    -3.082022    13.85758
     capcheither20 |   3.047237   2.133657     1.43   0.153    -1.134654    7.229129
   regchangeeither |   1.713628   1.301272     1.32   0.188    -.8368185    4.264074
      chTEAltorBmt |   .7458795   1.250344     0.60   0.551    -1.704749    3.196508
           alformA |   2.448111   1.558102     1.57   0.116    -.6057126    5.501936
             demdA |   1.287935   1.694944     0.76   0.447    -2.034094    4.609964
         asymmetry |  -1.643171   .9003435    -1.83   0.068    -3.407812    .1214697
          nomicoop |  -2.713557   1.163421    -2.33   0.020    -4.993821   -.4332933
            treaty |   1.517199   2.179552     0.70   0.486    -2.754645    5.789042
           milinst |   5.023342   2.020347     2.49   0.013     1.063534     8.98315
              time |  -.1214053   .2719923    -0.45   0.655    -.6545004    .4116897
        timesquare |  -.0028777   .0100448    -0.29   0.775    -.0225652    .0168098
          timecube |   .0000865    .000122     0.71   0.478    -.0001526    .0003257
             _cons |  -3.186679   1.364883    -2.33   0.020    -5.861802   -.5115572
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat8 |   3.927346   1.034434     3.80   0.000     1.899894    5.954799
num_dems_on_border |  -.3040659   .1211904    -2.51   0.012    -.5415948    -.066537
       num_borders |   .1232498   .0620013     1.99   0.047     .0017294    .2447701
           coldwar |   .4000256   .3026642     1.32   0.186    -.1931853    .9932366
       Lenergy_pop |  -.1512982   .0820848    -1.84   0.065    -.3121815    .0095851
           Oil_exp |   .6746757   .5077597     1.33   0.184     -.320515    1.669866
           maj_pow |   .4440264   .4978744     0.89   0.372    -.5317895    1.419842
         kgd_rival |   .0059427   .3998441     0.01   0.988    -.7777374    .7896228
             _cons |  -4.926452   .5382183    -9.15   0.000    -5.981341   -3.871564
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -551.16543
rescale:       log pseudolikelihood = -338.69399
rescale eq:    log pseudolikelihood = -338.69399

initial:       log pseudolikelihood = -338.69399
rescale:       log pseudolikelihood = -338.69399
rescale eq:    log pseudolikelihood = -338.69399
Iteration 0:   log pseudolikelihood = -338.69399  
Iteration 1:   log pseudolikelihood = -319.13528  (not concave)
Iteration 2:   log pseudolikelihood = -318.38648  (not concave)
Iteration 3:   log pseudolikelihood = -318.16075  (not concave)
Iteration 4:   log pseudolikelihood =   -318.028  (not concave)
Iteration 5:   log pseudolikelihood = -317.89658  (not concave)
Iteration 6:   log pseudolikelihood = -317.48397  (not concave)
Iteration 7:   log pseudolikelihood = -317.10067  (not concave)
Iteration 8:   log pseudolikelihood = -316.62135  (not concave)
Iteration 9:   log pseudolikelihood = -315.92494  (not concave)
Iteration 10:  log pseudolikelihood = -315.78303  (not concave)
Iteration 11:  log pseudolikelihood = -315.65976  (not concave)
Iteration 12:  log pseudolikelihood = -315.54081  (not concave)
Iteration 13:  log pseudolikelihood = -315.39264  (not concave)
Iteration 14:  log pseudolikelihood = -315.18577  (not concave)
Iteration 15:  log pseudolikelihood = -315.07022  (not concave)
Iteration 16:  log pseudolikelihood = -314.89957  (not concave)
Iteration 17:  log pseudolikelihood = -314.76924  (not concave)
Iteration 18:  log pseudolikelihood = -314.63963  (not concave)
Iteration 19:  log pseudolikelihood = -314.13089  
Iteration 20:  log pseudolikelihood =  -313.6652  
Iteration 21:  log pseudolikelihood = -306.58579  (not concave)
Iteration 22:  log pseudolikelihood = -306.17577  (not concave)
Iteration 23:  log pseudolikelihood = -305.95763  (not concave)
Iteration 24:  log pseudolikelihood = -305.90442  (not concave)
Iteration 25:  log pseudolikelihood = -305.86307  (not concave)
Iteration 26:  log pseudolikelihood = -305.84096  (not concave)
Iteration 27:  log pseudolikelihood = -305.81656  
Iteration 28:  log pseudolikelihood =  -305.7949  (backed up)
Iteration 29:  log pseudolikelihood = -305.61676  
Iteration 30:  log pseudolikelihood = -305.60966  
Iteration 31:  log pseudolikelihood =  -305.6095  
Iteration 32:  log pseudolikelihood =  -305.6095  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      38.51
Log pseudolikelihood =  -305.6095               Prob > chi2       =     0.0002

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.526743   6.221777     0.89   0.374    -6.667717     17.7212
     capcheither20 |   3.005019    2.48761     1.21   0.227    -1.870606    7.880644
   regchangeeither |   1.707668   1.304877     1.31   0.191    -.8498443     4.26518
      chTEAltorBmt |   .7883689   1.336487     0.59   0.555    -1.831098    3.407836
           alformA |   2.495976   1.816747     1.37   0.169    -1.064782    6.056735
             demdA |    1.36503   2.102741     0.65   0.516    -2.756268    5.486328
         asymmetry |  -1.592761   .9277498    -1.72   0.086    -3.411117    .2255955
          nomicoop |  -2.606033   1.201705    -2.17   0.030    -4.961332   -.2507338
            treaty |    1.48717   2.736643     0.54   0.587    -3.876551    6.850891
           milinst |   4.877844   3.033413     1.61   0.108    -1.067537    10.82323
              time |   -.122884   .2832207    -0.43   0.664    -.6779864    .4322184
        timesquare |  -.0026748   .0101955    -0.26   0.793    -.0226577     .017308
          timecube |   .0000839   .0001229     0.68   0.495    -.0001569    .0003247
             _cons |  -3.253264   1.686629    -1.93   0.054    -6.558997     .052468
-------------------+----------------------------------------------------------------
G                  |
       TerrThreat9 |    4.44719    1.00597     4.42   0.000     2.475525    6.418855
num_dems_on_border |  -.2684461   .1215009    -2.21   0.027    -.5065834   -.0303088
       num_borders |   .1158065   .0636843     1.82   0.069    -.0090123    .2406254
           coldwar |   .5126739   .3269413     1.57   0.117    -.1281193    1.153467
       Lenergy_pop |  -.1565657   .0840286    -1.86   0.062    -.3212588    .0081274
           Oil_exp |    .673662   .5202787     1.29   0.195    -.3460655     1.69339
           maj_pow |   .3664562   .5232278     0.70   0.484    -.6590514    1.391964
         kgd_rival |   .0118707   .3957077     0.03   0.976    -.7637021    .7874434
             _cons |  -5.053535   .5871166    -8.61   0.000    -6.204262   -3.902807
------------------------------------------------------------------------------------
.initial:      log pseudolikelihood = -547.27306
rescale:       log pseudolikelihood = -337.91421
rescale eq:    log pseudolikelihood = -337.91421

initial:       log pseudolikelihood = -337.91421
rescale:       log pseudolikelihood = -337.91421
rescale eq:    log pseudolikelihood = -337.91421
Iteration 0:   log pseudolikelihood = -337.91421  
Iteration 1:   log pseudolikelihood = -319.81403  (not concave)
Iteration 2:   log pseudolikelihood =  -319.1779  (not concave)
Iteration 3:   log pseudolikelihood = -318.94153  (not concave)
Iteration 4:   log pseudolikelihood = -318.81818  (not concave)
Iteration 5:   log pseudolikelihood = -318.62492  (not concave)
Iteration 6:   log pseudolikelihood = -318.44223  (not concave)
Iteration 7:   log pseudolikelihood = -316.40384  (not concave)
Iteration 8:   log pseudolikelihood = -316.15316  (not concave)
Iteration 9:   log pseudolikelihood = -315.99956  (not concave)
Iteration 10:  log pseudolikelihood = -315.85481  (not concave)
Iteration 11:  log pseudolikelihood = -315.55448  (not concave)
Iteration 12:  log pseudolikelihood = -315.38703  
Iteration 13:  log pseudolikelihood = -311.13882  (backed up)
Iteration 14:  log pseudolikelihood = -307.00844  
Iteration 15:  log pseudolikelihood = -306.15839  
Iteration 16:  log pseudolikelihood = -306.08157  
Iteration 17:  log pseudolikelihood = -306.05034  
Iteration 18:  log pseudolikelihood = -306.04991  
Iteration 19:  log pseudolikelihood = -306.04991  

                                                Number of obs     =      6,395
                                                Wald chi2(13)     =      39.50
Log pseudolikelihood = -306.04991               Prob > chi2       =     0.0002

                                (Std. Err. adjusted for 223 clusters in atopidphase)
------------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
B                  |
        wcchangedA |   5.561572   6.051641     0.92   0.358    -6.299427    17.42257
     capcheither20 |   2.931116    2.18173     1.34   0.179    -1.344996    7.207228
   regchangeeither |   1.674707   1.218147     1.37   0.169    -.7128172    4.062231
      chTEAltorBmt |   .7613579   1.212771     0.63   0.530     -1.61563    3.138346
           alformA |   2.431836   1.552443     1.57   0.117    -.6108962    5.474569
             demdA |   1.416006   2.000565     0.71   0.479    -2.505029    5.337041
         asymmetry |  -1.619648   .8998336    -1.80   0.072    -3.383289    .1439935
          nomicoop |  -2.606034   1.212839    -2.15   0.032    -4.983155   -.2289125
            treaty |   1.543111   2.367606     0.65   0.515    -3.097313    6.183534
           milinst |   4.938343   2.400285     2.06   0.040     .2338716    9.642814
              time |  -.1197001   .2677865    -0.45   0.655    -.6445519    .4051517
        timesquare |  -.0027226   .0100329    -0.27   0.786    -.0223868    .0169416
          timecube |   .0000843   .0001227     0.69   0.492    -.0001562    .0003248
             _cons |  -3.250517   1.555421    -2.09   0.037    -6.299087   -.2019473
-------------------+----------------------------------------------------------------
G                  |
      TerrThreat10 |    3.92785   .9053669     4.34   0.000     2.153364    5.702337
num_dems_on_border |  -.2779923   .1232338    -2.26   0.024    -.5195261   -.0364585
       num_borders |   .1218116   .0617088     1.97   0.048     .0008646    .2427586
           coldwar |   .4845752   .3064781     1.58   0.114    -.1161108    1.085261
       Lenergy_pop |  -.1563106   .0841339    -1.86   0.063    -.3212101    .0085889
           Oil_exp |   .6618007    .504988     1.31   0.190    -.3279575    1.651559
           maj_pow |   .3613345   .5189555     0.70   0.486    -.6557996    1.378469
         kgd_rival |   .0145894   .3958528     0.04   0.971    -.7612678    .7904467
             _cons |  -5.007077   .5562646    -9.00   0.000    -6.097336   -3.916819
------------------------------------------------------------------------------------
.
.         rubin;

.         /* -estout- is necessary to use -estimates store- */    
>                 estout , cells(b(star fmt(3)) se(par fmt(3)) ) starlevels(* .05) style(tex);

            &           . \\
            &        b/se \\
B           &             \\
wcchangedA  &       5.504 \\
            &     (5.507) \\
capcheither20&       2.996 \\
            &     (2.251) \\
regchangeeither&       1.699 \\
            &     (1.276) \\
chTEAltorBmt&       0.763 \\
            &     (1.255) \\
alformA     &       2.447 \\
            &     (1.626) \\
demdA       &       1.358 \\
            &     (1.924) \\
asymmetry   &      -1.620 \\
            &     (0.908) \\
nomicoop    &      -2.652*\\
            &     (1.198) \\
treaty      &       1.525 \\
            &     (2.387) \\
milinst     &       4.949*\\
            &     (2.434) \\
time        &      -0.123 \\
            &     (0.273) \\
timesquare  &      -0.003 \\
            &     (0.010) \\
timecube    &       0.000 \\
            &     (0.000) \\
_cons       &      -3.226*\\
            &     (1.520) \\
G           &             \\
TerrThreat10&       4.062*\\
            &     (1.025) \\
num_dems_on_border&      -0.292*\\
            &     (0.123) \\
num_borders &       0.122 \\
            &     (0.063) \\
coldwar     &       0.446 \\
            &     (0.312) \\
Lenergy_pop &      -0.153 \\
            &     (0.083) \\
Oil_exp     &       0.670 \\
            &     (0.512) \\
maj_pow     &       0.417 \\
            &     (0.516) \\
kgd_rival   &       0.007 \\
            &     (0.398) \\
_cons       &      -4.979*\\
            &     (0.558) \\

.                 matrix rename ll ll_full;

.                 matrix fitB = e(b);

.                 matrix fitSE = e(V);

.         estimates store full;

.                         /* Table 1 results */
>         #delimit;
delimiter now ;
.         estout LMV LMV2 full, stats(ll N )
>         cells(b(fmt(3) star) se(par))
>         modelwidth(8)
>         starlevels(* 0.05) legend
>         varwidth(15)
>         style(tex) replace;

               &     LMV &    LMV2 &    full \\
               &    b/se &    b/se &    b/se \\
main           &         &         &         \\
wcchangedA     &   0.889*&   0.910*&   5.504 \\
               & (0.436) & (0.444) & (5.507) \\
capcheither20  &   0.803*&   0.877*&   2.996 \\
               & (0.330) & (0.340) & (2.251) \\
regchangeeither&   0.131 &   0.195 &   1.699 \\
               & (0.308) & (0.308) & (1.276) \\
chTEAltorBmt   &   0.421 &   0.425 &   0.763 \\
               & (0.270) & (0.278) & (1.255) \\
alformA        &   1.070*&   1.064*&   2.447 \\
               & (0.253) & (0.261) & (1.626) \\
demdA          &  -1.322*&  -1.341*&   1.358 \\
               & (0.393) & (0.401) & (1.924) \\
asymmetry      &  -0.408 &  -0.503 &  -1.620 \\
               & (0.259) & (0.265) & (0.908) \\
nomicoop       &  -0.746*&  -0.746*&  -2.652*\\
               & (0.257) & (0.261) & (1.198) \\
treaty         &  -0.083 &  -0.134 &   1.525 \\
               & (0.354) & (0.355) & (2.387) \\
milinst        &   0.557*&   0.575*&   4.949*\\
               & (0.180) & (0.186) & (2.434) \\
time           &  -0.086 &  -0.069 &  -0.123 \\
               & (0.077) & (0.076) & (0.273) \\
timesquare     &   0.001 &  -0.000 &  -0.003 \\
               & (0.004) & (0.004) & (0.010) \\
timecube       &   0.000 &   0.000 &   0.000 \\
               & (0.000) & (0.000) & (0.000) \\
_cons          &  -4.448*&  -4.464*&  -3.226*\\
               & (0.440) & (0.455) & (1.520) \\
G              &         &         &         \\
TerrThreat10   &         &         &   4.062*\\
               &         &         & (1.025) \\
num_dems_on_border&         &         &  -0.292*\\
               &         &         & (0.123) \\
num_borders    &         &         &   0.122 \\
               &         &         & (0.063) \\
coldwar        &         &         &   0.446 \\
               &         &         & (0.312) \\
Lenergy_pop    &         &         &  -0.153 \\
               &         &         & (0.083) \\
Oil_exp        &         &         &   0.670 \\
               &         &         & (0.512) \\
maj_pow        &         &         &   0.417 \\
               &         &         & (0.516) \\
kgd_rival      &         &         &   0.007 \\
               &         &         & (0.398) \\
_cons          &         &         &  -4.979*\\
               &         &         & (0.558) \\
ll             &-352.394 &-339.988 &         \\
N              &6612.000 &6395.000 &         \\
* p<0.05

.                 matrix list ll_full;

symmetric ll_full[1,1]
            c1
r1  -306.90924

.         /* Figure 1: Density of Territorial Threat and Frequency of Violations.*/               
>         keep if GL==1;
(447 observations deleted)

.                 egen terrthreat_bin = cut(Threat_combine), at(0(0.005)1);

.         egen tot_vio = total(violate), by(terrthreat_bin);

.         #delimit;
delimiter now ;
.         twoway kdensity Threat_combine || bar tot_vio terrthreat_bin, barw(.007) scheme(s1mono) 
>                 legend(lab(1 "Density of Observations") lab(2 "Violations") symx(*.5))
>                 xlabel(0(.1).7)
>                 ytitle("Number of Violations") xtitle("Territorial Threat") 
>                 note("Note: The frequency of violations is overlayed with the kernel density of Territorial Threat within the"
>                         "sample from Table 1 Model 3.");

.         graph save fig1, replace asis;
(note: file fig1.gph not found)
file fig1.gph saved

. /*Rainey test for neglible effect */
>         /* Collapse data to mean/median and expand for simulations */
>         collapse        (mean)  Lenergy_pop time num_dems_on_border num_borders 
>                                 (median)  
>                                         demdA Oil_exp cold  
>                                                         nomicoop treaty asymmetry milinst regchangeeither chTEAltorBmt capcheither20
>                                                         wcchangedA alformA maj_pow kgd_rival
>                                         Threat_combine;

.         expand 10000;
(9,999 observations created)

.         gen timesquare = time^2;

.  gen timecube = time^3;

.         drawnorm beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14
>         gamma1  gamma3 gamma4 gamma5 gamma6 gamma7 gamma8 gamma9 gamma10, 
>                 means(fitB) cov(fitSE);

.         drawnorm beta1_lmv beta2_lmv beta3_lmv beta4_lmv beta5_lmv beta6_lmv beta7_lmv 
>                 beta8_lmv beta9_lmv beta10_lmv beta11_lmv beta12_lmv beta13_lmv beta14_lmv, 
>                 means(lmv_b) cov(lmv_se);

.         /* Generate latent value for relevancy equation */
>         gen double gbhat = gamma1*Threat_combine  + gamma3*num_dems_on_border + gamma4*num_borders + gamma5*cold +
>                                                 gamma6*Lenergy_pop + gamma7*Oil + gamma8*maj_pow + gamma9*kgd_rival + gamma10;

.         /* Generate latent value for outcome equation, varying change in leader's societal coalition */
>         gen double xbhat_0 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*demdA + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         gen double xbhat_1 = beta1*1 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*demdA + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         /* Generate latent value for replication of Leeds et al, varying change in leader's societal coalition */
>         gen double xbhat_lmv_0 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*demdA + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         gen double xbhat_lmv_1 = beta1_lmv*1 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*demdA + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         /* Generate latent value for outcome equation, varying democracy */                     
>         gen double xbhat_d0 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*0 + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         gen double xbhat_d1 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*1 + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         /* Generate latent value for replication of Leeds et al, varying democracy */   
>         gen double xbhat_lmv_d0 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*0 + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         gen double xbhat_lmv_d1 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*1 + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.                                 /* Generate predicted probabilities for change in leader's societal coalition 
>         for each condition in both the split-sample and replication equations */                                
>         gen double G = 1/(1+exp(-gbhat));

.         gen double F_0 = 1/(1+exp(-xbhat_0));

.         gen double F_1 = 1/(1+exp(-xbhat_1));

.         gen double vio_0 = G*F_0;

.         gen double vio_1 = G*F_1;

.         gen double lmv_0 = 1/(1+exp(-xbhat_lmv_0));

.         gen double lmv_1 = 1/(1+exp(-xbhat_lmv_1));

.         /* Generate predicted probabilities for democracy for each condition in both
>         the split-sample and replication equations */   
>         gen double vio_d1 = G*(1/(1+exp(-xbhat_d1)));

.         gen double vio_d0 = G*(1/(1+exp(-xbhat_d0)));

.         gen double lmv_d0 = 1/(1+exp(-xbhat_lmv_d0));

.         gen double lmv_d1 = 1/(1+exp(-xbhat_lmv_d1));

.                                         gen double lmv_fd_d = lmv_d1 - lmv_d0;

.         gen double vio_fd_d = vio_d1 - vio_d0;

.         gen double lmv_fd_sc = lmv_1 - lmv_0;

.         gen double vio_fd_sc = vio_1 - vio_0;

.         /* Calculate mean and standard devation of predicted probabilities, removing extreme values */                          
>         collapse (mean) lmv_fd_d vio_fd_d lmv_fd_sc vio_fd_sc 
>                          (p2) lmv_lo_d=lmv_fd_d vio_lo_d=vio_fd_d lmv_lo_sc=lmv_fd_sc vio_lo_sc=vio_fd_sc 
>                          (p98) lmv_hi_d=lmv_fd_d vio_hi_d=vio_fd_d lmv_hi_sc=lmv_fd_sc vio_hi_sc=vio_fd_sc;

.         sum lmv_lo_d lmv_fd_d lmv_hi_d vio_lo_d vio_fd_d vio_hi_d
>                 lmv_lo_sc lmv_fd_sc lmv_hi_sc vio_lo_sc vio_fd_sc vio_hi_sc;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    lmv_lo_d |          1   -.0052659           .  -.0052659  -.0052659
    lmv_fd_d |          1   -.0024452           .  -.0024452  -.0024452
    lmv_hi_d |          1   -.0008669           .  -.0008669  -.0008669
    vio_lo_d |          1   -.0004788           .  -.0004788  -.0004788
    vio_fd_d |          1    .0015798           .   .0015798   .0015798
-------------+---------------------------------------------------------
    vio_hi_d |          1    .0102182           .   .0102182   .0102182
   lmv_lo_sc |          1   -.0000313           .  -.0000313  -.0000313
   lmv_fd_sc |          1    .0055709           .   .0055709   .0055709
   lmv_hi_sc |          1    .0191999           .   .0191999   .0191999
   vio_lo_sc |          1   -.0004768           .  -.0004768  -.0004768
-------------+---------------------------------------------------------
   vio_fd_sc |          1    .0081302           .   .0081302   .0081302
   vio_hi_sc |          1    .0242178           .   .0242178   .0242178

.         /* Figure 2: Predicted Probabilities of an Alliance Violation, Democracy, and Territorial Threat */
>         /* Load data tempfile */
>         use `full', clear;

.                 /* Collapse data to mean/median and expand for simulations */
>         collapse        (mean)  Lenergy_pop time num_dems_on_border num_borders 
>                                 (median)  
>                                         demdA Oil_exp cold  
>                                                         nomicoop treaty asymmetry milinst regchangeeither chTEAltorBmt capcheither20
>                                                         wcchangedA alformA maj_pow kgd_rival
>                                 (p2) terrthreat_min=Threat_combine (p98) terrthreat_max=Threat_combine;

.                 expand 100;
(99 observations created)

.                 gen terrthreat = terrthreat_min + (terrthreat_max - terrthreat_min)*(_n-1)/_N;

.                 expand 100;
(9,900 observations created)

.                 gen timesquare = time^2;

.  gen timecube = time^3;

.                 drawnorm beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14
>                 gamma1  gamma3 gamma4 gamma5 gamma6 gamma7 gamma8 gamma9 gamma10, 
>                                 means(fitB) cov(fitSE);

.                 drawnorm beta1_lmv beta2_lmv beta3_lmv beta4_lmv beta5_lmv beta6_lmv beta7_lmv beta8_lmv beta9_lmv beta10_lmv beta11_lmv beta12_lmv beta13_lmv beta14_lmv, means(lmv_b) cov(lmv_se);

.         /* Generate latent value for relevancy equation */
>         gen double gbhat = gamma1*terrthreat  + gamma3*num_dems_on_border + gamma4*num_borders + gamma5*cold +
>                                                 gamma6*Lenergy_pop + gamma7*Oil + gamma8*maj_pow + gamma9*kgd_rival + gamma10;

.         /* Generate latent value for outcome equation, varying change in leader's societal coalition */
>         gen double xbhat_0 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*demdA + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         gen double xbhat_1 = beta1*1 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*demdA + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         /* Generate latent value for replication of Leeds et al, varying change in leader's societal coalition */
>         gen double xbhat_lmv_0 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*demdA + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         gen double xbhat_lmv_1 = beta1_lmv*1 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*demdA + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         /* Generate latent value for outcome equation, varying democracy */             
>         gen double xbhat_d0 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*0 + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         gen double xbhat_d1 = beta1*0 + beta2*capcheither20 + beta3*regchangeeither + beta4*chTEAltorBmt + beta5*alformA + beta6*1 + 
>                                                 beta7*asymmetry + beta8*nomicoop + beta9*treaty + beta10*milinst + beta11*time + beta12*timesquare + beta13*timecube + beta14;

.         /* Generate latent value for replication of Leeds et al, varying democracy */   
>         gen double xbhat_lmv_d0 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*0 + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.         gen double xbhat_lmv_d1 = beta1_lmv*0 + beta2_lmv*capcheither20 + beta3_lmv*regchangeeither + beta4_lmv*chTEAltorBmt + beta5_lmv*alformA + 
>                                         beta6_lmv*1 + beta7_lmv*asymmetry + beta8_lmv*nomicoop + beta9_lmv*treaty + beta10_lmv*milinst + beta11_lmv*time + 
>                                         beta12_lmv*timesquare + beta13_lmv*timecube + beta14_lmv;

.                                                                         /* Generate predicted probabilities for change in leader's societal coalition 
>         for each condition in both the split-sample and replication equations */
>         gen double G = 1/(1+exp(-gbhat));

.         gen double vio_0 = G*(1/(1+exp(-xbhat_0)));

.         gen double vio_1 = G*(1/(1+exp(-xbhat_1)));

.         gen double lmv_0 = 1/(1+exp(-xbhat_lmv_0));

.         gen double lmv_1 = 1/(1+exp(-xbhat_lmv_1));

.         /* Generate predicted probabilities for democracy for each condition in both
>         the split-sample and replication equations */   
>         gen double vio_d1 = G*(1/(1+exp(-xbhat_d1)));

.         gen double vio_d0 = G*(1/(1+exp(-xbhat_d0)));

.         gen double lmv_d0 = 1/(1+exp(-xbhat_lmv_d0));

.         gen double lmv_d1 = 1/(1+exp(-xbhat_lmv_d1));

.         /* Plot the predicted probabilities of alliance violation across terroritorial 
>         threat under varying conditions of change in leader's societal coalition and democracy */
>         twoway  lowess vio_d1 terrthreat,  sort lpattern(solid) color(red) lwidth(thick)|| 
>                         lowess vio_d0 terrthreat, sort lpattern(solid) color(black)  ||
>                         lowess lmv_d1 terrthreat, sort lpattern(dash) color(red) lwidth(thick) ||
>                         lowess lmv_d0 terrthreat, sort lpattern(dash) color(black)              
>                                         title("Democracy")
>                                         ylabel(0(.01).04)
>                                         xlabel(0(.05).42)
>                                         scheme(s1mono) 
>                                         ytitle("") xtitle("Territorial Threat") 
>                                         legend(lab(1  "Democracy (w/ Relevance)") lab(2 "Non-Democracy (w/ Relevance)") 
>                                                         lab(3 "Democracy (Reduced)") lab(4 "Non-Democracy (Reduced)") rows(4) symx(*.5));

.                                                                 graph save fig2a, replace;
(note: file fig2a.gph not found)
(file fig2a.gph saved)

.                 #delimit;
delimiter now ;
.         twoway  lowess vio_1 terrthreat,  sort lpattern(solid) color(red) lwidth(thick)|| 
>                         lowess vio_0 terrthreat, sort lpattern(solid) color(black)  ||
>                         lowess lmv_1 terrthreat, sort lpattern(dash) color(red) lwidth(thick) ||
>                         lowess lmv_0 terrthreat, sort lpattern(dash) color(black) 
>                                         title("{&Delta} in Leader's SC")
>                                         ylabel(0(.01).04)
>                                         xlabel(0(.05).42)
>                                         scheme(s1mono) 
>                                         ytitle("") xtitle("Territorial Threat") 
>                                         legend(lab(1  "{&Delta} in Leader's SC (w/ Relevance)") lab(2 "No {&Delta} in Leader's SC (w/ Relevance)") 
>                                                         lab(3 "{&Delta} in Leader's SC (Reduced)") lab(4 "No {&Delta} in Leader's SC (Reduced)") rows(4) symx(*.5));

.                                                 graph save fig2b, replace;
(note: file fig2b.gph not found)
(file fig2b.gph saved)

.         /* Graph combine predicted probability for Dem, Change in LSC and Territorial Threat*/
>         #delimit;
delimiter now ;
.         graph combine fig2a.gph fig2b.gph, scheme(s1mono) row(1) ycommon
>                                         l1title("Pr(Violation)")
>                                         note("Note: Estimates from Table 1, Models 2 and 3. All variables held at mean or median. Figure reports the" 
>                                                  "predicted probabilities for the middle 95% of values of Territorial Threat from the samples.");

.         graph save fig2, replace asis;
(note: file fig2.gph not found)
file fig2.gph saved

. /* Beyond alliances: Trade application */       
> /*Preamble*/
> clear;

. program drop _all;

. clear matrix;

. set seed 17;

.         /* Calculate Rubin formula for uncertainty adding R-squared */
>                 capture program drop rubin;

.                 program define rubin;
  1.                         local names: colnames(Q1);
  2.                         /* MI param estimates */
>                         matrix Q = (Q1 + Q2 + Q3 + Q4 + Q5 + Q6 + Q7 + Q8 + Q9 + Q10)/10;
  3.                         /* MI covariances     */
>                         matrix W = (W1 + W2 + W3 + W4 + W5 + W6 + W7 + W8 + W9 + W10)/10;
  4.                         /* MI R-squared */
>                         matrix r2 = (r21 + r22 + r23 + r24 + r25 + r26 + r27 + r28 + r29 + r210)/10;
  5.                         local  k = colsof(Q);
  6.                         forvalues i=1/10 {;
  7.                           matrix QQ=Q`i'-Q;
  8.                           if `i'==1 {;
  9.                                 matrix B=(QQ)'*QQ;
 10.                                 };
 11.                           else matrix B = B + (QQ)'*QQ;
 12.                         };
 13.                         /* Covariance adjustment */
>                         matrix B=B/(10-1);
 14.                                         /* Final covariance   */
>                         matrix V=W+(1+1/10)*B;
 15.                                                         ereturn post Q V ;
 16.                 end;

.                                 /* Load trade data */           
>         use NiemanGibler_demdiff_trade, clear;

.         /* OLS for trade with democracy and territorial threat */
>         forvalues i=1/10 {;
  2.         areg ltrade BothDem_Threatmin`i' OneDem_Threatmin`i' BothDem OneDem threat_min`i' bothin onein gsp ldist lrgdp lrgdppc regional custrict comlang border landl island lareap comcol colony curcol comctry , a(year
> ) robust cluster(dyad);
  3.         matrix Q`i' = e(b);
  4.                 matrix W`i' = e(V);
  5.                 matrix  r2`i' = e(r2);
  6.                 nois _dots `i' 0;
  7.         };

Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.16
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9786

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin1 |  -2.761146    .728437    -3.79   0.000    -4.188999   -1.333293
 OneDem_Threatmin1 |  -1.221862   .4347049    -2.81   0.005    -2.073953   -.3697712
           BothDem |   .2040526   .0451556     4.52   0.000     .1155405    .2925648
            OneDem |   .0932329   .0342748     2.72   0.007     .0260488    .1604171
       threat_min1 |   .1271884   .3425186     0.37   0.710    -.5442027    .7985794
            bothin |  -.0528731   .0541543    -0.98   0.329    -.1590242     .053278
             onein |  -.0485581   .0496584    -0.98   0.328    -.1458966    .0487804
               gsp |    .830011   .0315622    26.30   0.000     .7681441    .8918779
             ldist |  -1.125077   .0220641   -50.99   0.000    -1.168327   -1.081828
             lrgdp |   .9171466   .0096653    94.89   0.000     .8982011    .9360921
           lrgdppc |   .3078736   .0144716    21.27   0.000      .279507    .3362402
          regional |   1.164538   .1079393    10.79   0.000     .9529596    1.376116
          custrict |   1.129162   .1235542     9.14   0.000     .8869761    1.371348
           comlang |    .309406   .0404099     7.66   0.000      .230196    .3886159
            border |   .5276755   .1097861     4.81   0.000     .3124772    .7428738
             landl |  -.2824443   .0313456    -9.01   0.000    -.3438866    -.221002
            island |   .0199842   .0364105     0.55   0.583    -.0513862    .0913546
            lareap |  -.0980169   .0080333   -12.20   0.000    -.1137634   -.0822704
            comcol |   .5901985   .0678968     8.69   0.000     .4571099    .7232871
            colony |   1.151632   .1159997     9.93   0.000     .9242545     1.37901
            curcol |   1.096609   .2360906     4.64   0.000     .6338335    1.559384
           comctry |   .0008891   1.085264     0.00   0.999    -2.126401    2.128179
             _cons |  -27.58345   .3758573   -73.39   0.000    -28.32019   -26.84671
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.02
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6487
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9787

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin2 |  -2.995469   .8226293    -3.64   0.000    -4.607953   -1.382984
 OneDem_Threatmin2 |  -1.333264   .4751145    -2.81   0.005    -2.264564   -.4019635
           BothDem |   .2088676   .0458504     4.56   0.000     .1189935    .2987418
            OneDem |   .0947402   .0344184     2.75   0.006     .0272747    .1622057
       threat_min2 |   .2869314   .3749044     0.77   0.444     -.447941    1.021804
            bothin |  -.0499688   .0542614    -0.92   0.357    -.1563299    .0563923
             onein |   -.046163   .0497231    -0.93   0.353    -.1436282    .0513021
               gsp |   .8330155   .0315513    26.40   0.000     .7711699     .894861
             ldist |  -1.126602   .0220927   -50.99   0.000    -1.169907   -1.083297
             lrgdp |    .916572   .0096696    94.79   0.000     .8976181     .935526
           lrgdppc |     .30913    .014486    21.34   0.000     .2807352    .3375249
          regional |   1.165939   .1075944    10.84   0.000      .955037    1.376841
          custrict |   1.129186   .1236058     9.14   0.000     .8868988    1.371473
           comlang |   .3069174   .0404131     7.59   0.000     .2277012    .3861336
            border |   .5232695   .1098428     4.76   0.000     .3079601    .7385789
             landl |  -.2800636   .0313316    -8.94   0.000    -.3414785   -.2186487
            island |   .0210054   .0364518     0.58   0.564     -.050446    .0924568
            lareap |  -.0977905    .008035   -12.17   0.000    -.1135403   -.0820407
            comcol |   .5905199   .0679042     8.70   0.000     .4574168     .723623
            colony |   1.159017   .1157949    10.01   0.000     .9320402    1.385993
            curcol |    1.09562   .2358355     4.65   0.000      .633345    1.557895
           comctry |   .0057363   1.081607     0.01   0.996    -2.114386    2.125859
             _cons |  -27.57602   .3760964   -73.32   0.000    -28.31323   -26.83881
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1535.45
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6487
                                                Root MSE          =     1.9785

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin3 |  -3.025121   .7751605    -3.90   0.000    -4.544559   -1.505683
 OneDem_Threatmin3 |  -1.381134   .4579467    -3.02   0.003    -2.278783   -.4834855
           BothDem |   .2147831   .0459791     4.67   0.000     .1246568    .3049095
            OneDem |   .0985818   .0345625     2.85   0.004     .0308337    .1663299
       threat_min3 |   .2290426   .3597611     0.64   0.524    -.4761465    .9342317
            bothin |  -.0519502   .0541609    -0.96   0.337    -.1581142    .0542138
             onein |  -.0475713   .0496555    -0.96   0.338     -.144904    .0497615
               gsp |   .8309597   .0315419    26.34   0.000     .7691326    .8927868
             ldist |  -1.125754   .0220681   -51.01   0.000    -1.169011   -1.082497
             lrgdp |   .9169391   .0096595    94.93   0.000     .8980048    .9358733
           lrgdppc |   .3082988   .0144657    21.31   0.000     .2799438    .3366538
          regional |   1.165441   .1077493    10.82   0.000     .9542356    1.376647
          custrict |   1.128491   .1236001     9.13   0.000     .8862153    1.370767
           comlang |   .3079217   .0404044     7.62   0.000     .2287226    .3871207
            border |   .5259766   .1096416     4.80   0.000     .3110616    .7408916
             landl |  -.2816593   .0313329    -8.99   0.000    -.3430768   -.2202418
            island |   .0180349   .0364857     0.49   0.621     -.053483    .0895527
            lareap |  -.0979096   .0080299   -12.19   0.000    -.1136495   -.0821697
            comcol |   .5918938   .0678932     8.72   0.000     .4588124    .7249752
            colony |   1.156633   .1157015    10.00   0.000     .9298397    1.383426
            curcol |   1.095648    .235936     4.64   0.000     .6331756     1.55812
           comctry |   .0075538   1.081872     0.01   0.994    -2.113087    2.128195
             _cons |   -27.5809   .3757623   -73.40   0.000    -28.31745   -26.84435
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1536.19
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6487
                                                Root MSE          =     1.9785

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin4 |  -2.987905    .751564    -3.98   0.000     -4.46109    -1.51472
 OneDem_Threatmin4 |  -1.319727   .4599542    -2.87   0.004    -2.221311   -.4181436
           BothDem |   .2062385   .0450973     4.57   0.000     .1178407    .2946363
            OneDem |   .0945108   .0342149     2.76   0.006     .0274441    .1615774
       threat_min4 |   .1500349   .3626619     0.41   0.679    -.5608403      .86091
            bothin |  -.0528112   .0542126    -0.97   0.330    -.1590766    .0534541
             onein |  -.0481335   .0496941    -0.97   0.333    -.1455419    .0492748
               gsp |   .8305552   .0315578    26.32   0.000     .7686969    .8924135
             ldist |  -1.126609   .0220739   -51.04   0.000    -1.169878   -1.083341
             lrgdp |   .9173881   .0096709    94.86   0.000     .8984316    .9363446
           lrgdppc |     .30767   .0144828    21.24   0.000     .2792814    .3360586
          regional |   1.161455   .1078165    10.77   0.000     .9501179    1.372793
          custrict |   1.127633   .1235959     9.12   0.000     .8853657    1.369901
           comlang |   .3077824   .0404067     7.62   0.000     .2285788     .386986
            border |   .5263786   .1095984     4.80   0.000     .3115483    .7412089
             landl |  -.2819582   .0313301    -9.00   0.000    -.3433702   -.2205462
            island |   .0202726   .0363788     0.56   0.577    -.0510357    .0915808
            lareap |   -.098164   .0080381   -12.21   0.000      -.11392   -.0824079
            comcol |    .592264   .0678608     8.73   0.000     .4592461     .725282
            colony |   1.154147   .1157856     9.97   0.000     .9271892    1.381106
            curcol |    1.09693   .2360211     4.65   0.000     .6342908    1.559569
           comctry |   .0023739   1.085386     0.00   0.998    -2.125156    2.129904
             _cons |  -27.57665   .3757857   -73.38   0.000    -28.31325   -26.84005
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.53
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9786

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin5 |  -3.296615   .8083413    -4.08   0.000    -4.881093   -1.712138
 OneDem_Threatmin5 |  -1.424683   .4771039    -2.99   0.003    -2.359883   -.4894831
           BothDem |   .2129613   .0455166     4.68   0.000     .1237415    .3021811
            OneDem |   .0970146     .03433     2.83   0.005     .0297224    .1643067
       threat_min5 |   .3298378   .3738386     0.88   0.378    -.4029453    1.062621
            bothin |  -.0493039   .0542157    -0.91   0.363    -.1555753    .0569675
             onein |  -.0457269   .0496969    -0.92   0.358    -.1431407     .051687
               gsp |    .832512   .0315511    26.39   0.000     .7706669    .8943571
             ldist |  -1.126764   .0220857   -51.02   0.000    -1.170056   -1.083473
             lrgdp |   .9168641   .0096671    94.84   0.000      .897915    .9358131
           lrgdppc |   .3086995   .0144834    21.31   0.000     .2803097    .3370893
          regional |   1.163917   .1076652    10.81   0.000     .9528762    1.374958
          custrict |   1.129432   .1235678     9.14   0.000     .8872193    1.371644
           comlang |   .3068384   .0404049     7.59   0.000     .2276383    .3860385
            border |   .5238322   .1096176     4.78   0.000     .3089642    .7387001
             landl |  -.2807627   .0313207    -8.96   0.000    -.3421563   -.2193691
            island |   .0206916   .0364281     0.57   0.570    -.0507133    .0920964
            lareap |  -.0979652   .0080355   -12.19   0.000    -.1137161   -.0822142
            comcol |   .5919062   .0678803     8.72   0.000       .45885    .7249624
            colony |   1.157926   .1157284    10.01   0.000     .9310799    1.384772
            curcol |   1.097739   .2356794     4.66   0.000       .63577    1.559708
           comctry |   .0033855   1.082917     0.00   0.998    -2.119305    2.126076
             _cons |  -27.57932   .3758395   -73.38   0.000    -28.31602   -26.84261
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.05
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6487
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9787

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin6 |   -3.12491   .8111309    -3.85   0.000    -4.714856   -1.534964
 OneDem_Threatmin6 |  -1.358268   .4523833    -3.00   0.003    -2.245011   -.4715242
           BothDem |   .2079399   .0452498     4.60   0.000      .119243    .2966368
            OneDem |   .0956895   .0341306     2.80   0.005      .028788    .1625909
       threat_min6 |   .4143957   .3516047     1.18   0.239    -.2748056    1.103597
            bothin |  -.0467356   .0542419    -0.86   0.389    -.1530583    .0595871
             onein |  -.0441815   .0497076    -0.89   0.374    -.1416163    .0532534
               gsp |   .8330908   .0315702    26.39   0.000     .7712082    .8949734
             ldist |  -1.126459   .0220959   -50.98   0.000     -1.16977   -1.083147
             lrgdp |   .9163606   .0096706    94.76   0.000     .8974047    .9353166
           lrgdppc |   .3093549   .0144931    21.34   0.000     .2809461    .3377637
          regional |   1.165495   .1075852    10.83   0.000     .9546113    1.376379
          custrict |   1.130964   .1235622     9.15   0.000     .8887621    1.373165
           comlang |   .3067978   .0404125     7.59   0.000     .2275828    .3860128
            border |   .5215536   .1098246     4.75   0.000     .3062798    .7368274
             landl |  -.2792307   .0313179    -8.92   0.000    -.3406188   -.2178427
            island |   .0238419   .0363877     0.66   0.512    -.0474839    .0951677
            lareap |  -.0977255   .0080367   -12.16   0.000    -.1134788   -.0819723
            comcol |   .5903412   .0679158     8.69   0.000     .4572155     .723467
            colony |    1.15833   .1159139     9.99   0.000     .9311201     1.38554
            curcol |   1.095138   .2359774     4.64   0.000     .6325847    1.557691
           comctry |   .0012516   1.084171     0.00   0.999    -2.123896    2.126399
             _cons |  -27.57973   .3760622   -73.34   0.000    -28.31688   -26.84259
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1536.16
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6487
                                                Root MSE          =     1.9785

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin7 |   -3.18478   .7886083    -4.04   0.000    -4.730578   -1.638982
 OneDem_Threatmin7 |  -1.425104   .4717236    -3.02   0.003    -2.349757   -.5004502
           BothDem |    .211593   .0454364     4.66   0.000     .1225305    .3006556
            OneDem |   .0968325   .0343003     2.82   0.005     .0295986    .1640665
       threat_min7 |   .2023737   .3696585     0.55   0.584    -.5222159    .9269633
            bothin |  -.0524854   .0541702    -0.97   0.333    -.1586675    .0536968
             onein |  -.0478278   .0496636    -0.96   0.336    -.1451763    .0495207
               gsp |   .8306646   .0315456    26.33   0.000     .7688302     .892499
             ldist |  -1.126024   .0220658   -51.03   0.000    -1.169277   -1.082772
             lrgdp |   .9171934   .0096591    94.96   0.000     .8982599    .9361268
           lrgdppc |   .3079174   .0144629    21.29   0.000     .2795678     .336267
          regional |   1.163665   .1077803    10.80   0.000      .952398    1.374931
          custrict |   1.128081   .1235943     9.13   0.000     .8858167    1.370346
           comlang |   .3079178   .0404013     7.62   0.000     .2287248    .3871107
            border |    .526647   .1095495     4.81   0.000     .3119125    .7413815
             landl |  -.2818661   .0313278    -9.00   0.000    -.3432735   -.2204588
            island |   .0189234   .0364232     0.52   0.603    -.0524718    .0903186
            lareap |  -.0980898   .0080323   -12.21   0.000    -.1138344   -.0823452
            comcol |   .5925733   .0678757     8.73   0.000      .459526    .7256206
            colony |   1.154955   .1157101     9.98   0.000     .9281453    1.381766
            curcol |   1.096263   .2359877     4.65   0.000     .6336896    1.558836
           comctry |   .0046401    1.08339     0.00   0.997    -2.118977    2.128257
             _cons |  -27.57922   .3757481   -73.40   0.000    -28.31575    -26.8427
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.23
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6487
                                                Root MSE          =     1.9786

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin8 |  -2.993593   .7471503    -4.01   0.000    -4.458127    -1.52906
 OneDem_Threatmin8 |  -1.295527    .439931    -2.94   0.003    -2.157862   -.4331918
           BothDem |   .2068165   .0450762     4.59   0.000       .11846    .2951731
            OneDem |   .0948481   .0341776     2.78   0.006     .0278545    .1618418
       threat_min8 |   .2418854   .3469088     0.70   0.486    -.4381112     .921882
            bothin |  -.0497352   .0541585    -0.92   0.358    -.1558945    .0564241
             onein |  -.0464185   .0496654    -0.93   0.350    -.1437707    .0509337
               gsp |   .8312572   .0315647    26.34   0.000     .7693854    .8931291
             ldist |  -1.126294   .0220735   -51.02   0.000    -1.169562   -1.083027
             lrgdp |   .9170179   .0096713    94.82   0.000     .8980607    .9359752
           lrgdppc |   .3083613   .0144781    21.30   0.000     .2799819    .3367407
          regional |   1.163075   .1077765    10.79   0.000     .9518161    1.374335
          custrict |   1.128903   .1235635     9.14   0.000     .8866991    1.371107
           comlang |   .3077549   .0403973     7.62   0.000     .2285698      .38694
            border |   .5248741   .1096665     4.79   0.000     .3099103     .739838
             landl |  -.2809376   .0313247    -8.97   0.000    -.3423391   -.2195361
            island |   .0215332   .0363777     0.59   0.554    -.0497729    .0928393
            lareap |  -.0979914   .0080387   -12.19   0.000    -.1137485   -.0822344
            comcol |   .5915052   .0678751     8.71   0.000     .4584591    .7245513
            colony |   1.155686   .1157408     9.99   0.000     .9288155    1.382556
            curcol |   1.095207   .2359477     4.64   0.000     .6327116    1.557702
           comctry |   .0024175   1.085401     0.00   0.998    -2.125141    2.129976
             _cons |  -27.58214   .3757587   -73.40   0.000    -28.31869   -26.84559
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1535.18
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9786

                                    (Std. Err. adjusted for 12,144 clusters in dyad)
------------------------------------------------------------------------------------
                   |               Robust
            ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------+----------------------------------------------------------------
BothDem_Threatmin9 |  -3.471172   .8843307    -3.93   0.000    -5.204601   -1.737743
 OneDem_Threatmin9 |  -1.505552   .5096133    -2.95   0.003    -2.504476    -.506629
           BothDem |   .2082584   .0453223     4.60   0.000     .1194195    .2970973
            OneDem |   .0956884   .0343102     2.79   0.005     .0284349    .1629418
       threat_min9 |   .3059537   .3983571     0.77   0.442    -.4748897    1.086797
            bothin |  -.0499931    .054213    -0.92   0.356    -.1562593     .056273
             onein |  -.0461765   .0496979    -0.93   0.353    -.1435923    .0512394
               gsp |   .8312746    .031564    26.34   0.000     .7694042    .8931451
             ldist |  -1.126428   .0220826   -51.01   0.000    -1.169714   -1.083143
             lrgdp |   .9168895   .0096688    94.83   0.000     .8979371    .9358419
           lrgdppc |   .3083942    .014489    21.28   0.000     .2799935    .3367948
          regional |   1.163052   .1077556    10.79   0.000     .9518337     1.37427
          custrict |   1.129754   .1235735     9.14   0.000     .8875302    1.371978
           comlang |    .307247   .0404058     7.60   0.000     .2280452    .3864489
            border |   .5247236   .1097084     4.78   0.000     .3096776    .7397695
             landl |  -.2811133   .0313289    -8.97   0.000     -.342523   -.2197036
            island |   .0214728   .0363938     0.59   0.555    -.0498648    .0928104
            lareap |  -.0979863   .0080363   -12.19   0.000    -.1137388   -.0822337
            comcol |   .5910543   .0678851     8.71   0.000     .4579887    .7241199
            colony |   1.155748   .1158089     9.98   0.000     .9287438    1.382752
            curcol |   1.095944   .2359877     4.64   0.000     .6333706    1.558517
           comctry |   .0011991   1.084824     0.00   0.999    -2.125228    2.127627
             _cons |  -27.57625   .3759564   -73.35   0.000    -28.31319   -26.83932
-------------------+----------------------------------------------------------------
              year |   absorbed                                      (52 categories)
.
Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.25
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6487
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9786

                                     (Std. Err. adjusted for 12,144 clusters in dyad)
-------------------------------------------------------------------------------------
                    |               Robust
             ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------------+----------------------------------------------------------------
BothDem_Threatmin10 |   -2.90664    .807343    -3.60   0.000    -4.489161   -1.324119
 OneDem_Threatmin10 |  -1.237839   .4816693    -2.57   0.010    -2.181988   -.2936907
            BothDem |   .2065096   .0457972     4.51   0.000     .1167398    .2962795
             OneDem |   .0926339   .0345379     2.68   0.007      .024934    .1603337
       threat_min10 |   .1230888   .3839132     0.32   0.749    -.6294424    .8756199
             bothin |  -.0530209   .0542623    -0.98   0.329    -.1593837    .0533419
              onein |  -.0483921   .0497262    -0.97   0.330    -.1458635    .0490793
                gsp |   .8317336   .0315617    26.35   0.000     .7698676    .8935996
              ldist |  -1.126553   .0220805   -51.02   0.000    -1.169834   -1.083272
              lrgdp |   .9170239   .0096765    94.77   0.000     .8980565    .9359913
            lrgdppc |   .3084291   .0144852    21.29   0.000     .2800357    .3368224
           regional |   1.163686   .1077819    10.80   0.000     .9524162    1.374956
           custrict |   1.127726   .1235826     9.13   0.000     .8854844    1.369967
            comlang |   .3077957   .0404132     7.62   0.000     .2285794     .387012
             border |   .5255336   .1098027     4.79   0.000     .3103027    .7407645
              landl |  -.2814524   .0313441    -8.98   0.000    -.3428919   -.2200129
             island |   .0194634   .0364534     0.53   0.593    -.0519911    .0909179
             lareap |  -.0979198    .008037   -12.18   0.000    -.1136736    -.082166
             comcol |   .5908129   .0678898     8.70   0.000      .457738    .7238878
             colony |   1.156488   .1158074     9.99   0.000     .9294866    1.383488
             curcol |   1.098123   .2356831     4.66   0.000     .6361465    1.560099
            comctry |   .0048176    1.08264     0.00   0.996     -2.11733    2.126965
              _cons |  -27.57611   .3759196   -73.36   0.000    -28.31297   -26.83924
--------------------+----------------------------------------------------------------
               year |   absorbed                                      (52 categories)
.
.         rubin;

.                 estout , cells(b(star fmt(3)) se(par fmt(3)) ) starlevels(* .05) style(tex);

            &           . \\
            &        b/se \\
BothDem_Threatmin10&      -3.075*\\
            &     (0.822) \\
OneDem_Threatmin10&      -1.350*\\
            &     (0.476) \\
BothDem     &       0.209*\\
            &     (0.046) \\
OneDem      &       0.095*\\
            &     (0.034) \\
threat_min10&       0.241 \\
            &     (0.380) \\
bothin      &      -0.051 \\
            &     (0.054) \\
onein       &      -0.047 \\
            &     (0.050) \\
gsp         &       0.832*\\
            &     (0.032) \\
ldist       &      -1.126*\\
            &     (0.022) \\
lrgdp       &       0.917*\\
            &     (0.010) \\
lrgdppc     &       0.308*\\
            &     (0.014) \\
regional    &       1.164*\\
            &     (0.108) \\
custrict    &       1.129*\\
            &     (0.124) \\
comlang     &       0.308*\\
            &     (0.040) \\
border      &       0.525*\\
            &     (0.110) \\
landl       &      -0.281*\\
            &     (0.031) \\
island      &       0.021 \\
            &     (0.036) \\
lareap      &      -0.098*\\
            &     (0.008) \\
comcol      &       0.591*\\
            &     (0.068) \\
colony      &       1.156*\\
            &     (0.116) \\
curcol      &       1.096*\\
            &     (0.236) \\
comctry     &       0.003 \\
            &     (1.084) \\
_cons       &     -27.579*\\
            &     (0.376) \\

.                 matrix B = e(b);

.                 matrix V = e(V);

.                 matrix rename  r2 r2_threat;

.                 estimates store threat;

.                         /* Identify common observations using mean territorial threat score from the 10 draws */        
>         areg ltrade BothDem_Threatmin OneDem_Threatmin BothDem OneDem threat_min bothin 
>                 onein gsp ldist lrgdp lrgdppc regional custrict comlang border landl island 
>                 lareap comcol colony curcol comctry , a(year) robust cluster(dyad);

Linear regression, absorbing indicators         Number of obs     =    233,990
                                                F(  22,  12143)   =    1534.90
                                                Prob > F          =     0.0000
                                                R-squared         =     0.6488
                                                Adj R-squared     =     0.6486
                                                Root MSE          =     1.9786

                                   (Std. Err. adjusted for 12,144 clusters in dyad)
-----------------------------------------------------------------------------------
                  |               Robust
           ltrade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
BothDem_Threatmin |   -3.09246   .7949142    -3.89   0.000    -4.650618   -1.534301
 OneDem_Threatmin |  -1.354268    .466703    -2.90   0.004    -2.269081   -.4394561
          BothDem |   .2096469   .0455052     4.61   0.000     .1204493    .2988444
           OneDem |   .0956815   .0343571     2.78   0.005      .028336     .163027
       threat_min |   .2371355   .3666891     0.65   0.518    -.4816335    .9559045
           bothin |  -.0510665   .0542057    -0.94   0.346    -.1573184    .0551853
            onein |  -.0469913   .0496889    -0.95   0.344    -.1443895    .0504069
              gsp |   .8314087   .0315569    26.35   0.000     .7695521    .8932653
            ldist |  -1.126283   .0220767   -51.02   0.000    -1.169557    -1.08301
            lrgdp |   .9169693   .0096675    94.85   0.000     .8980196    .9359191
          lrgdppc |   .3083542   .0144796    21.30   0.000     .2799718    .3367366
         regional |   1.163963   .1077457    10.80   0.000     .9527638    1.375161
         custrict |   1.128833   .1235832     9.13   0.000     .8865902    1.371076
          comlang |   .3076219   .0404073     7.61   0.000     .2284172    .3868266
           border |   .5250753   .1096905     4.79   0.000     .3100645    .7400862
            landl |  -.2812011    .031331    -8.98   0.000    -.3426149   -.2197873
           island |    .020245   .0364254     0.56   0.578    -.0511547    .0916447
           lareap |  -.0979718    .008035   -12.19   0.000    -.1137217    -.082222
           comcol |   .5914954   .0678863     8.71   0.000     .4584273    .7245634
           colony |   1.156025   .1157849     9.98   0.000     .9290678    1.382981
           curcol |   1.096374   .2359212     4.65   0.000     .6339307    1.558817
          comctry |   .0036448   1.083776     0.00   0.997    -2.120729    2.128019
            _cons |  -27.57862   .3758667   -73.37   0.000    -28.31538   -26.84187
------------------+----------------------------------------------------------------
             year |   absorbed                                      (52 categories)

.         gen GN =1 if e(sample)==1;
(607 missing values generated)

.                                         /* Figure 3 (and Figure A.4): Predicted Trade*/
>         keep if GN==1;
(607 observations deleted)

.         /* Collapse data to mean/median and expand for simulations */
>         collapse (mean) threat=threat_min  (median) ldist lrgdp lrgdppc lareap bothin onein gsp  regional custrict comlang border landl island comcol colony curcol comctry (min) threat_min=threat_min (max) threat_max=thr
> eat_min;

.         expand 100;
(99 observations created)

.                         replace threat = threat_min + (_n/_N)*(threat_max - threat_min);
(100 real changes made)

.         expand 100;
(9,900 observations created)

.         drawnorm b_BothDem_Threatmin b_OneDem_Threatmin b_BothDem b_OneDem b_threat_min b_bothin b_onein b_gsp b_ldist b_lrgdp b_lrgdppc b_regional b_custrict b_comlang b_border b_landl b_island b_lareap b_comcol b_colon
> y b_curcol b_comctry b_cons, means(B) cov(V);

.         /* Generate (unlogged) predicted values for two democracies, one democracy, and no democracy condititions */
>         gen pr_trade_both = exp(b_BothDem_Threatmin*threat + b_BothDem + b_threat_min*threat + b_bothin*bothin + b_onein*onein + b_gsp*gsp + b_ldist*ldist + b_lrgdp*lrgdp +
>                 b_lrgdppc*lrgdppc + b_regional*regional + b_custrict*custrict + b_comlang*comlang +  b_border*border + b_landl*landl + b_island*island + b_lareap*lareap + 
>                 b_comcol*comcol + b_colony*colony + b_curcol*curcol + b_comctry*comctry + b_cons);

.         gen pr_trade_one = exp(b_OneDem_Threatmin*threat + b_OneDem + b_threat_min*threat + b_bothin*bothin + b_onein*onein + b_gsp*gsp + b_ldist*ldist + b_lrgdp*lrgdp +
>                 b_lrgdppc*lrgdppc + b_regional*regional + b_custrict*custrict + b_comlang*comlang +  b_border*border + b_landl*landl + b_island*island + b_lareap*lareap + 
>                 b_comcol*comcol + b_colony*colony + b_curcol*curcol + b_comctry*comctry + b_cons);

.         gen pr_trade_none = exp(b_threat_min*threat + b_bothin*bothin + b_onein*onein + b_gsp*gsp + b_ldist*ldist + b_lrgdp*lrgdp +
>                 b_lrgdppc*lrgdppc + b_regional*regional + b_custrict*custrict + b_comlang*comlang +  b_border*border + b_landl*landl + b_island*island + b_lareap*lareap + 
>                 b_comcol*comcol + b_colony*colony + b_curcol*curcol + b_comctry*comctry + b_cons);

.         /* Calculate mean predicted values */   
>         collapse (mean) pr_trade_both pr_trade_one pr_trade_none, by(threat);

.         /*Plot mean predicted (unlogged) trade values for two, one, and no democracy conditions */      
>                   twoway lowess pr_trade_both threat, scheme(s1color)
>                         lcolor(blue) 
>                         || lowess pr_trade_one threat, 
>                         lcolor(red) lwidth(medthick) lpattern (longdash)
>                         ||      lowess  pr_trade_none threat, 
>                         lcolor(black ) lwidth(medium ) lpattern(dash )
>                         ylabel(0(5000)15000)
>                         xtitle("Territorial Threat (weak link)")
>                         legend(lab(1  "Both Dem") lab(2 "One Dem") lab(3 "No Dem") symx(*.5) row(1));

.                         graph save fig3, replace asis;
(note: file fig3.gph not found)
file fig3.gph saved

.         log close;
      name:  <unnamed>
       log:  C:\Users\markd\Dropbox\Mark Research\Working Papers\Gibler-Nieman\Split-sample alliance\JoP Final\Replication\Main Analysis\NiemanGibler_JOP_demdiff.log
  log type:  text
 closed on:  25 Sep 2020, 13:23:35
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
